Can int (*)[]
be an incomplete type?
C 2018 6.2.5 1 says:
At various points within a translation unit an object type may be incomplete (lacking sufficient information to determine the size of objects of that type) or complete (having sufficient information).
Thus it seems that if the size of a type is known, the type is complete. 6.2.6.1 28 specifies that certain types of pointers must have the same sizes (pointers to void
and characters, pointers to compatible types, pointers to structures, and pointers to unions), but pointers to other types may vary.
In a C implementation where all pointers, or all pointers to arrays of int
, have the same size, then the size of int (*)[]
is known, so it would be complete. In an implementation that, say, uses different pointers for large arrays, the size would not be known, so it is incomplete.
As M.M points out, a structure must not contain a member with incomplete type, except a final flexible array member, per a constraint in 6.7.2.1 3. This suggests that an implementation with one size of pointers must accept struct { int (*p)[]; }
while an implementation that has different sizes for such arrays must diagnose a constraint violation. (This in turn means such a declaration is not part of strictly conforming C.)