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

Joerg Sonnenberger joerg at britannica.bec.de
Tue Jul 12 08:07:48 PDT 2011


On Tue, Jul 12, 2011 at 03:46:06PM +0100, Peter Geoghegan wrote:
> Consider the common idiom in C, of a struct with its last declared
> type is an array like this:
> 
> typedef struct
> {
>         int id;
>         int values[1];
> } my_struct;

C99 explicitly allows declaring values without a size for cases like
this. E.g. use

typedef struct
{
	int id;
	int values[];
} my_struct;

I consider this warning completely acceptable and correct, even if it
takes a bit to clean up old source code.

Joerg



More information about the cfe-dev mailing list