[Bug c/104711] Unnecessary -Wshift-negative-value warning

segher at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 1 17:51:06 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104711

--- Comment #8 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Arnd's request was to not have -Wshift-negative-value implied by -W, or at
least not if -fwrapv (-pedantic would be wrong btw, the standard does not
require a diagnostic here, and that is what -pedantic does / is for).

My opinion is it does not belong in -W at all.

X << 0 is undefined behaviour for negative X (in C.  This whole PR is about C).

> I suppose you are asking for an option to turn all left shifts into logical shifts?

The request is to not warn for left shift of a negative number with -W.  It
is fine to do that with -Wshift-negative-value, but that option should not be
implied by -W.


More information about the Gcc-bugs mailing list