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

            Bug ID: 81230
           Summary: False -Wimplicit-fallthrough when case has braces
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org
  Target Milestone: ---

[forwarded from https://bugs.debian.org/860263]

moving the fall through comment behind the closing brace avoids the warning as
well.

$ gcc-7 -Wextra -o foo foo.c
foo.c: In function 'main':
foo.c:6:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
    argc = 0;
    ~~~~~^~~~
foo.c:9:3: note: here
   default:
   ^~~~~~~
$ cat foo.c
int main(int argc, char **argv)
{
    switch (argc)
    {
        case 1: {
            argc = 0;
            //fallthrough
        }
        default:
            argc = 1;
            break;
    }

    return 0;
}

Removing the braces for "case 1:" removes the warning.

Reply via email to