[cfe-dev] -Warray-bounds seems over-zealous on Clang
thakis at chromium.org
Tue Jul 12 17:06:22 PDT 2011
On Tue, Jul 12, 2011 at 4:59 PM, Peter Geoghegan <peter at 2ndquadrant.com> wrote:
> On 13 July 2011 00:28, David Blaikie <dblaikie at gmail.com> wrote:
>> I think someone mentioned the idea of adding a separate warning for this
>> narrower case and, in the case of compiling for c99, suggesting a fixup of
>> using a flexible array. In the case of c89 at least it'd be a separate
>> warning that, if the pattern is used extensively in the codebase, could be
>> disabled separately from the more general warning (which would be adjusted
>> to ignore these cases).
>> This would allow for the bug that was mentioned to have been found, while
>> allowing you to disable this warning if you don't think the chance of such
>> bugs coming up is worth the code hygiene cost of the above construct or the
>> move to c99 would be worthwhile in your case.
> While strictly speaking that would be a valid solution, it would also
> be overly-complex considering the benefits IMHO. I'd now have a flag
> to pass to Clang, but only to Clang, despite the fact that it's
> supposed to be a drop-in replacement for GCC. I'd now have to
> explicitly indicate that I was using C89.
In the past, warnings that warns about a common pattern but also find
bugs have been kept on-by-default. Search this list for
> Once again, the burden would be on application developers who are just
> using a demonstrably mainstream idiom, all to prevent obvious bugs in
> poorly written applications under very specific circumstances, that
> will only occur a vanishingly small number of times, and will never be
> noticed by GCC either.
This bug is in ICU, which is pretty commonly used. Someone (me) posted
an example where this warning found a bug within 2h of Chris asking
for it, so maybe it's not as vanishingly small as you think.
> Peter Geoghegan http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training and Services
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
More information about the cfe-dev