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

Peter Geoghegan peter at 2ndquadrant.com
Tue Jul 12 15:39:18 PDT 2011


On 12 July 2011 18:29, Chris Lattner <clattner at apple.com> wrote:
> 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 would think it reasonable if the warning was disabled for this exact
pattern only.

Disabling -Wno-array-bounds clearly isn't a practical measure, as most
of the ways that that can trigger a warning are perfectly valid. I
wouldn't be opposed to showing the warning where the struct is known
to have been declared on the stack, but going that far probably isn't
worth the effort.

On 12 July 2011 17:45, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> Just because you don't agree doesn't make it unreasonable. The behavior
> of the code doesn't change with the standard level -- you are still
> declaring an array and overflowing it.

I agree, it doesn't. The fact that this causes warnings for a very
common pattern makes it unreasonable.

-- 
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services




More information about the cfe-dev mailing list