gcc 4.1 regression for adjusted function declaration?

Andrew Pinski pinskia@physics.uc.edu
Thu Feb 16 19:41:00 GMT 2006


On Feb 16, 2006, at 2:32 PM, Andrew Pinski wrote:

> Even more important:
> http://gcc.gnu.org/ml/gcc/2005-02/msg00026.html
>
> Which is the answer you are looking for:
>
>
> But the constraint in C99 is on array declarators, "The element type 
> shall
> not be an incomplete or function type.".  This applies to the syntax
> whenever it describes an array type even that array type then gets
> adjusted to a pointer type.  In C90, without the constraint, there was
> undefined behavior for an array of incomplete type, even in parameter
> context: DR#047 example 3 is almost exactly this case
>
>    /* 3 */ struct S *g(struct S a[]) {return a; }
>
> and was said to involve undefined behavior.  "However, there is 
> nothing to
> suggest that a not-strictly-conforming array type can magically be
> transformed into a strictly conforming pointer parameter via this 
> rule."

And this was a documented change too:
http://gcc.gnu.org/gcc-4.0/changes.html

Arrays of incomplete element type are invalid in C. GCC now issues an 
error for such arrays. Declarations such as extern struct s x[]; (where 
struct s has not been defined) can be moved after the definition of 
struct s. Function parameters declared as arrays of incomplete type can 
instead be declared as pointers

-- Pinski



More information about the Gcc mailing list