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: "daniel.marjamaki at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jul 2011 13:28:59 +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
Daniel MarjamÃki <daniel.marjamaki at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.marjamaki at gmail
| |dot com
--- Comment #7 from Daniel MarjamÃki <daniel.marjamaki at gmail dot com> 2011-07-29 13:28:41 UTC ---
In my experience this type of check is really noisy if there is a warning for
every fall through.
I recommend that the warning is written only if the fall through cause
redundant or bad behaviour. such as:
switch (foo) {
case 1: x = y; // <- redundant assignment
case 2: x = z;
};
Or:
switch (foo) {
case 1: p = NULL;
case 2: *p = 2; // fall through => NULL pointer dereference
};