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

            Bug ID: 77955
           Summary: -Wimplicit-fallthrough=1 issue
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: trippels at gcc dot gnu.org
  Target Milestone: ---

markus@x4 /tmp % cat fall.c
void bar(int);

void foo(int i) {
  switch (i) {
  case 1: {
    bar(1);
    // fall-through
  }
  case 2:
    bar(2);
  default:
    break;
  }
}
markus@x4 /tmp % gcc -Wimplicit-fallthrough=1 -c fall.c
fall.c: In function ‘foo’:
fall.c:6:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     bar(1);
     ^~~~~~
fall.c:9:3: note: here
   case 2:
   ^~~~

As you can see gcc issues a bogus warning and doesn't warn for the case 2
fallthrough.

Reply via email to