[cfe-dev] -Warray-bounds seems over-zealous on Clang

Chris Lattner clattner at apple.com
Tue Jul 12 20:39:19 PDT 2011


On Jul 12, 2011, at 5:15 PM, John McCall wrote:

> Gentlemen, this is Clang;  we can differentiate between '1' as a literal
> value and '1' resulting from a template- or macro-metaprogrammed
> computation.  The former case has no legitimate examples and can
> be safely assumed to be a pre-C99 flexible array member.  The latter
> case should still be diagnosed using -Warray-bounds.

+1.  

The point of a warning is to be useful, not abusive.  If going to extreme measures makes the warning more useful and causes it to be more useful by default, then I think it is worth it.

Clang needs to be tolerant of different programming styles and constraints.  While it is never possible to make everyone happy, disabling the warning in a very-likely false positive, or splitting that case out into a sub -W flag is the right way to go.

-Warray-bounds-single-element seems like overkill to me, but is completely feasible.

-Chris



More information about the cfe-dev mailing list