4 ms·
> -Wxor-used-as-pow This seems to only trigger in limited circumstances, one of my favorite accidentally true expression is still warning-free: printf("%d
by omoikane 4y ago
> -Wxor-used-as-pow
This seems to only trigger in limited circumstances, one of my favorite accidentally true expression is still warning-free:
printf("%d\n", 2^5); // Warning here.
assert((3^2) + (4^2) == (5^2)); // No warnings.
https://gcc.godbolt.org/z/4GqdEMfPb https://gcc.godbolt.org/z/4GqdEMfPb
- michaelhoffman 4y agoMy understanding is it only triggers when the left side is 2 or 10.
- ape4 4y agoThat's quite specific
- michaelhoffman 4y agoIt's based on the errors the proposers actually found in the wild, which seem to mostly be people attempting to use constant powers of 2 or 10.
- cozzyd 4y agoshould also include e.
- Y_Y 4y agoExcellent. Now I'm wondering if Fermat's Last Theorem has a bitwise analogue.
- kps 4y agoBitwise multiplication is bitwise ‘and’, so exponentiation (repeated multiplication) is the identity, so aⁿ+bⁿ=cⁿ iff a+b=c. I have a truly remarkable proof of this, but my filesystem is full.
- Someone 4y ago> Now I'm wondering if Fermat's Last Theorem has a bitwise analogue. It hasn’t in this sense. The ^n operator flips the ‘one’ bits in n in its argument, so for any n, we have a = a^n^n So, for all a and b, a^n + b^n = ((a^n + b^n)^n)^n that makes c = (a^n + b^n)^n a solution to a^n + b^n = c^n and that means we can find a c for every n, a and b.
- Y_Y 4y agoNeat proof!