In C, should I be allowed to use pointers to arrays of incomplete types?

Viewed 438

The IAR Embedded C compiler is happy with this, and I assumed it was correct C code:

struct incomplete;
typedef struct incomplete (*why_not)[2];
struct incomplete {struct incomplete *known_to_work;} array[2];
why_not ok = &array;

However, gcc and clang choke on the definition of why_not:

incomplete.c:2:29: error: array type has incomplete element type ‘struct incomplete’
 typedef struct incomplete (*why_not)[2];
                             ^

Technically, there is no reason to reject a definition of a "pointer to array of incomplete" type. After all, the structure definition is needed only where such a variable is dereferenced, or some pointer arithmetics is performed.

I'm eager to hide structure definitions where possible.

What does the C standard say about this?

2 Answers
Related