public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104711] New: Unnecessary -Wshift-negative-value warning
@ 2022-02-27 21:27 arnd at linaro dot org
  2022-02-27 21:40 ` [Bug c/104711] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: arnd at linaro dot org @ 2022-02-27 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104711
           Summary: Unnecessary -Wshift-negative-value warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

During the discussion of increasing the C standard version of the Linux kernel
fro m gnu89 to gnu99 or higher, it turned out that gcc warns about code that
shifts negative signed integers [2].

This is undefined behavior in standard C99, but defined as a GNU extension in
GCC.[3]. This warning is enabled by default at the -Wextra level for C99/GNU99
or higher, but disabled for C89/GNU89. In clang, the warning is enabled by
default at the -Wall level but in turn disabled when building with -fwrapv or
-fno-strict-overflow (as the Linux kernel does).

It would be nice if future compiler releases could either demote the warning
from being enabled at -Wextra to -Wpedantic, or follow clang and disable it
when used with -fwrapv/-fno-strict-overflow.

[1] https://lore.kernel.org/lkml/20220227010956.GW614@gate.crashing.org/
[2] https://www.godbolt.org/z/s1TzxrGz4
[3] https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Integers-implementation.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-05-11  6:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-27 21:27 [Bug c/104711] New: Unnecessary -Wshift-negative-value warning arnd at linaro dot org
2022-02-27 21:40 ` [Bug c/104711] " pinskia at gcc dot gnu.org
2022-02-27 22:37 ` segher at gcc dot gnu.org
2022-02-27 22:38 ` segher at gcc dot gnu.org
2022-02-27 22:42 ` segher at gcc dot gnu.org
2022-03-01  7:58 ` rguenth at gcc dot gnu.org
2022-03-01  9:07 ` jakub at gcc dot gnu.org
2022-03-01 14:11 ` jakub at gcc dot gnu.org
2022-03-01 17:51 ` segher at gcc dot gnu.org
2022-03-09  8:16 ` cvs-commit at gcc dot gnu.org
2022-03-29  5:53 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:25 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:25 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).