[PATCH] Introduce -Wimplicit-fallthrough={0,1,2,3,4,5}

Jakub Jelinek jakub@redhat.com
Wed Oct 12 10:50:00 GMT 2016


On Wed, Oct 12, 2016 at 12:33:58PM +0200, Bernd Schmidt wrote:
> On 10/12/2016 12:26 PM, Jakub Jelinek wrote:
> >What do you mean at most?  level 0 is the warning disabled, that is the
> >default except for -Wextra.
> 
> I think level 0 has to be on the table for -Wextra as well, depending on the
> signal-to-noise ratio of level 1.

-Wextra includes various style warnings (we have some of them even in
-Wall), and the intent with this warning is to improve the code base,
let users look at places where there are implicit fallthrough not explicitly
marked so, and spend the few seconds to mark intentional fallthrough if it
is indeed intentional.
So for this warning, the question is what is a false positive; I really
don't expect the code in the wild broken so much that every place the
warning is emitted is a missing break;, 1:50 or 1:100 ratio is just fine,
by adding (more or less free form, which is why we have levels)
comments about it you express the intent and that will survive often for a
long time without need for another analysis.

If -Wimplicit-fallthrough isn't included in -Wextra, most of the people will
not even know there is this warning, and the code base in the wild will
remain with lots of bugs.  Remember how many bugs in gcc sources alone this
warning allowed to fix.

	Jakub



More information about the Gcc-patches mailing list