Question

Is there any situation where a complete type in a translation unit can become an incomplete type? The following statement in the footnote of the C11 standard (Section 6.2.5) prompted this question.

A type may be incomplete or complete throughout an entire translation unit, or it may change states at different points within a translation unit.

Examples abound for incomplete types becoming complete types in a translation unit. But I was wondering if the opposite scenario was ever possible. My gut would tell me it's not.

Was it helpful?

Solution

A example of a complicated situation would be the following

extern double A[];

double* f(void) {
  extern double A[5];
  enum { a = sizeof(A), }; //< A has complete type
  return A;
}

enum { b = sizeof(A), }; //< A has incomplete type: error

double A[5];

enum { c = sizeof(A), }; //< A has complete type
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top