This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 4.1 regression for adjusted function declaration?



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]