https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125346
Bug ID: 125346
Summary: break of named loop suppresses -Wimplicit-fallthrough
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Keywords: diagnostic, false-negative
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rasheeqhere at gmail dot com
Target Milestone: ---
The following does not generate a warning:
$ cat >main.c <<"EOF"
extern int decide_something();
extern void do_something();
int main() {
loop: while(true) switch(decide_something()) {
case 42:
do_something();
// should warn here!
case -1:
break loop;
}
}
EOF
$ gcc -std=c2y -Wimplicit-fallthrough=5 -c main.c
# no output
$ uname -mo; gcc --version
x86_64 GNU/Linux
gcc (GCC) 16.1.0
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The behavior is the same on 15.2 and on trunk (07aa3ec). Compiler Explorer:
https://godbolt.org/z/aMqTvqrEq
This is probably the same behavior as in 91432: GCC doesn't want to warn if a
case falls through to a case that immediately does break;, because
break;
case -1:
break;
is the same as
[[fallthrough]];
case -1:
break;
But now, with named loops, there really is a difference between
break;
case -1:
break loop;
and
[[fallthrough]];
case -1:
break loop;
So there should be a warning if [[fallthrough]] is missing in the latter case.