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.

Reply via email to