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

Peter Geoghegan peter at 2ndquadrant.com
Tue Jul 12 16:59:22 PDT 2011


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.

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.

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




More information about the cfe-dev mailing list