[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#860263: gcc-7: False -Wimplicit-fallthrough when case has braces



Source: gcc-7
Version: 7-20170407-1
Severity: normal

$ 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.

-- System Information:
Debian Release: 9.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


Reply to: