public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/104504] New: spurious -Wswitch-unreachable warning with -ftrivial-auto-var-init=zero
@ 2022-02-11 15:15 nsz at gcc dot gnu.org
  2022-02-11 18:06 ` [Bug middle-end/104504] " kees at outflux dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2022-02-11 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104504
           Summary: spurious -Wswitch-unreachable warning with
                    -ftrivial-auto-var-init=zero
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

reduced from linux code on which gcc-12 warns now:

int foo(int x) {
    switch(x) {
        int y;
        /* spuriously warns with -ftrivial-auto-var-init=zero */
    default:
        y = x * 2;
        return y;
    }
}

$ gcc -Wall -ftrivial-auto-var-init=zero -c a.c
a.c: In function 'foo':
a.c:3:13: warning: statement will never be executed [-Wswitch-unreachable]
    3 |         int y;
      |             ^

i can see why gcc warns, but it would be better not to.

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

end of thread, other threads:[~2022-02-12 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 15:15 [Bug middle-end/104504] New: spurious -Wswitch-unreachable warning with -ftrivial-auto-var-init=zero nsz at gcc dot gnu.org
2022-02-11 18:06 ` [Bug middle-end/104504] " kees at outflux dot net
2022-02-12  0:41 ` kees at outflux dot net
2022-02-12  9:18 ` jakub at gcc dot gnu.org
2022-02-12 18:12 ` kees at outflux dot net
2022-02-12 20:22 ` pinskia 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).