Bug#860263: gcc-7: False -Wimplicit-fallthrough when case has braces
Control: forwarded -1 https://gcc.gnu.org/PR81230
Control: tags -1 + upstream
On 13.04.2017 19:32, James McCoy wrote:
> 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.
moving the fall through comment behind the closing brace avoids the warning as well.
Reply to: