[cfe-dev] -Warray-bounds seems over-zealous on Clang
Peter Geoghegan
peter at 2ndquadrant.com
Fri Aug 5 02:33:46 PDT 2011
On 5 August 2011 10:16, Chandler Carruth <chandlerc at google.com> wrote:
> 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.
This is the exact behaviour I was looking for, because, as you know, I
think the chances of the "consider flexible arrays" warning being
useful was very close to zero, and there is really no reason to not
give the warning under circumstances that are not exactly consistent
with the use of the idiom.
Thank you Chandler, and thank you Nicola.
--
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services
More information about the cfe-dev
mailing list