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: error: array type has incomplete element type


"Joseph S. Myers" <joseph@codesourcery.com> writes:

| On Wed, 2 Feb 2005, Ralf Corsepius wrote:
| 
| > * What is wrong with such kind of declarations?
| 
| Arrays are of object types only.  Incomplete types are not object types.
| 
| > Has the language changed, have constructs like the one above been
| > obsoleted by C-standards or did the code implicitly rely on a gcc
| > proprietary extension to C?
| 
| It has been confirmed since 1992 that such declarations are not valid C 
| <http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_047.html>.


Notice however, that it is an area where C differs from C++.  So
beware if you happen to have that in a code at the intersection of C
and C++ program fragments.
C++ 3.9/6:
   A class that has been declared but not defined, or an array of
   unknown size or of incomplete element type, is an
   incompletely-defined object type.38) Incompletely-defined object 
   types and the void types are incomplete types (3.9.1). Objects
   shall not be defined to have an incomplete type. 

3.9/7:
   A class type (such as "class X") might be incomplete at one point
   in a translation unit and complete later on; the type "class X"
   is the same type at both points. The declared type of an array
   object might be an array of incomplete class type and therefore
   incomplete; if the class type is completed later on in the
   translation unit, the array type becomes complete; the array type
   at those two points is the same type. The declared type of an array
   object might be an array of unknown size and therefore be
   incomplete at one point in a translation unit and complete later
   on; the array types at those two points ("array of unknown bound of
   T" and "array of N T") are different types. The type of a pointer
   to array of unknown size, or of a type defined by a typedef
   declaration to be an array of unknown size, cannot be completed.

-- Gaby


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