3.9/6 N3797:
[...]
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.
It sounds like a pointer to an array of unknown size is an incomplete type. If so we couldn't define an object of a pointer to array of unknown size. But it is not true, because we can define an array of unknown bound.
#include <iostream>
using std::cout;
using std::endl;
int (*a)[] = (int(*)[])0x4243afff;
int main()
{
}
It compiles fine.
DEMO
We could't do it if it were incomplete type. Indeed:
3.9/5:
Objects shall not be defined to have an incomplete type
The Standard previously defined an incomplete types as follows 3./5:
A class that has been declared but not defined, an enumeration type in
certain contexts (7.2), or an array of unknown size or of incomplete
element type, is an incompletely-defined object type.
Incompletely defined object types and the void types are incomplete
types (3.9.1).
Which means the pointer to an incomplete type is complete. Contradiction?
So where I'm wrong in my reasoning?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…