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

Chandler Carruth chandlerc at google.com
Fri Aug 5 02:16:05 PDT 2011


On Fri, Jul 29, 2011 at 3:56 AM, Peter Geoghegan <peter at 2ndquadrant.com>wrote:

> So, my second blog post on this subject has a benchmark that sees
> clang do quite well:
>
>
> http://pgeoghegan.blogspot.com/2011/07/could-clang-displace-gcc-generally-part.html
>
> It was picked up by Reddit, and has received a few thousand unique
> visitors since yesterday.
>
> Anyway, I'm disappointing that no headway has been made on this issue
> after a week. Chandler, could you please let me know if it is still
> your intent to fix this problem, and if so whether or not you favour
> suppressing it in C99 too?


Sorry about the delays here. My time kept geting co-opted by burning fires
on other fronts.

Chris ended up doing a quick patch for this a couple of days ago, and I've
now gone through and applied most of the logic discussed here as of r136965.

Specifically, the array-bounds warning is now suppressed iff:
1) The array size is one, and
2) The array is declared as the last field in a struct, and
3) The array's size is written as a literal '1' rather than being expanded
from a macro or substituted from a template argument

I've not added a warning in C99 or C++ modes which suggests flexible arrays
as its not clear to me how productive such a warning would be. Given the
restrictions above, it is very unlikely to represent a bug (i hope!) and so
warning seems more noise than signal.

Let me know if you hit issues with this logic.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110805/0c9077c7/attachment.html>


More information about the cfe-dev mailing list