[cfe-commits] r150055 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/Sema/switch.c

Joerg Sonnenberger joerg at britannica.bec.de
Wed Feb 8 14:55:57 PST 2012


On Wed, Feb 08, 2012 at 09:50:22AM -0800, Ted Kremenek wrote:
> On Feb 7, 2012, at 10:50 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> > I think it's a real pity to separate the two warnings, but I can
> > understand the limitation/problem. Having this flag under /no/ group
> > at all does leave me a bit concerned that it'll never be found/used,
> > though.
> 
> The rollout of new warnings is largely political.  Believe it or not,
> many users have complained to use when we roll out new warnings under
> -Wall.  Such users expect -Wall to have consistent behavior between releases.

The critical question is whether (a) a warning finds a useful number of
real bugs (b) doesn't have too many false positives and (c) has a
reasonable workaround for the cases of (b).

My problem is that a lot of code uses default: branches either for
proper diagnostics in debugging situations or for making sure that bad
values trigger determistic failure cases.

This warning is nice and good for an "isolated" code base like LLVM,
where malicious input is not expected and not more important than any
other bug. It doesn't work too well in central libraries or a kernel,
where defensive programming is essential. Indicently, a switch statement
that covers all enum values and a default branch is the typical way to
check the validity of the interface. Unless there is a clear way to mark
the default statement in this case as "invalid error case", I don't
think it is a good idea to make this part of -Wall. Of course, having a
proper way to do that would be a good idea anyway.

Joerg



More information about the cfe-commits mailing list