[Bug c/7652] -Wswitch-break : Warn if a switch case falls through
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jun 23 10:38:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
--- Comment #18 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to David Binderman from comment #17)
> (In reply to Daniel Marjamäki from comment #7)
> > 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;
> > };
>
> I'd be happy with gcc warning for this kind of problem.
>
> This specific case should be easier to catch than the
> general case.
In fact, this case is the same outside a switch:
x = y;
x = z;
I think this could be useful, but it will depend a lot on the implementation.
So we need someone to implement it ;-)
More information about the Gcc-bugs
mailing list