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

Douglas Gregor dgregor at apple.com
Tue Jul 12 09:50:40 PDT 2011


On Jul 12, 2011, at 8:54 AM, Peter Geoghegan wrote:

> Saying "just use C99" isn't a practical solution. This is a mature
> project with a large codebase, that targets many compilers, including,
> for a large number of reasons, Visual Studio - Microsoft have
> absolutely no interest in pursuing C99 support.

Flexibly array members are a common extension, as are zero-length arrays, specifically for this purpose. I'm guessing that you didn't try our suggestion before dismissing it out of hand.

> Besides, the chances of Clang actually helpfully diagnosing a problem
> with the delta between how GCC does -Warray-bounds and how Clang does
> it are slim - how often are these problems statically detectable? This
> is C.

We have empirical evidence that it *does* find bugs, otherwise we wouldn't still have the warning.

> Even if your position wasn't unreasonable, which it is, Clang still
> gives this warning when the -c89 flag is given.


Asking you to consider using a feature from a 12-year-old standard that was specifically designed for what you're trying to do hardly falls into the category of "unreasonable", even if you consider it to be impractical.

The *practical* solution for you is to turn off the warning with -Wno-array-bounds.

	- Doug



More information about the cfe-dev mailing list