Remove misleading XOR
Timm Bäder
tbaeder@redhat.com
Wed Feb 24 13:46:50 GMT 2021
On 24/02/2021 14:16, Mark Wielaard wrote:
> Hmmm. I am not sure why that doesn't work. What if you make them
> explicitly unsinged (adding u at the end). Or does it simply ignore
> the values and just warn because it sees the macro name and not an
> explicit number?
>
> I think I don't really understand anymore what this warning is warning
> about. Could you give an example of where this would flag something
> that we would like to fix?
I found https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90885, which has a
few more use-cases (in the form of tweets but anyway). GCC might also
get this warning in the future.
For the clang implementation, see https://reviews.llvm.org/D63423
So it only seems to warn for 2 ^ x because that's a common error:
#define NO_RESIZING 0x0u
#define CLEANING 0x2u
int main(void) {
unsigned p = CLEANING ^ NO_RESIZING;
unsigned j = NO_RESIZING ^ CLEANING;
unsigned k = 17 ^ 3;
}
This code only warns for the declaration of p.
> Maybe it is easiest to just suppress this warning, when is it enabled?
That's fine with me, I just didn't want to add compiler-specific flags
but I guess we can just check for -Wno-xor-used-as-pow and add that when
the compiler supports it.
- Timm
--
Red Hat GmbH, http://www.de.redhat.com/, Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Michael O'Neill, Tom Savage, Eric
Shander
More information about the Elfutils-devel
mailing list