<div class="gmail_quote">On Tue, Jul 12, 2011 at 10:29 AM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank" class="cremed">clattner@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><br>
On Jul 12, 2011, at 9:50 AM, Douglas Gregor wrote:<br>
<br>
>> Besides, the chances of Clang actually helpfully diagnosing a problem<br>
>> with the delta between how GCC does -Warray-bounds and how Clang does<br>
>> it are slim - how often are these problems statically detectable? This<br>
>> is C.<br>
><br>
> We have empirical evidence that it *does* find bugs, otherwise we wouldn't still have the warning.<br>
<br>
</div>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.</blockquote><div>

<br></div><div>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.</div>
<div><br></div><div>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.</div>

</div>