[cfe-dev] -Warray-bounds seems over-zealous on Clang
chandlerc at google.com
Tue Jul 12 13:08:28 PDT 2011
On Tue, Jul 12, 2011 at 10:29 AM, Chris Lattner <clattner at apple.com> wrote:
> On Jul 12, 2011, at 9:50 AM, Douglas Gregor wrote:
> >> Besides, the chances of Clang actually helpfully diagnosing a problem
> >> with the delta between how GCC does -Warray-bounds and how Clang does
> >> it are slim - how often are these problems statically detectable? This
> >> is C.
> > We have empirical evidence that it *does* find bugs, otherwise we
> wouldn't still have the warning.
> Do we have empirical evidence that it finds bugs in arrays with exactly 1
> element? I think we should just disable it in the case that the array has a
> single element. This really is a common pattern.
I tend to agree, but maybe there is a good compromise. What about changing
this warning to whitelist only one-element arrays which are inside of some
record type? That would still catch local arrays, global arrays, etc.
We could even then add a special (extension?) warning for one-element arrays
inside of record types which are accessed passed the bounds only in modes
where flexible array members are available, maybe even with a fixit note
that converts the declaration.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev