This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/7652] -Wswitch-break : Warn if a switch case falls through
- From: "eric at brouhaha dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Feb 2012 01:04:18 +0000
- Subject: [Bug c/7652] -Wswitch-break : Warn if a switch case falls through
- Auto-submitted: auto-generated
- References: <bug-7652-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
--- Comment #9 from Eric Smith <eric at brouhaha dot com> 2012-02-21 01:04:18 UTC ---
Or, instead of a pragma as I proposed in me previous comment, the warning would
be avoided by using a goto to the next case label. Updated version of the
example from the first comment, which would not trip the warning:
case (foo)
{
case 1: case 2:
printf ("case 1 and 2\n");
break;
case 3: case 4:
printf ("case 3 and case 4\n");
goto 5;
case 5:
printf ("case 5 (and fallthrough for cases 3 and 4\n");
}