Specifically, I'm asking if typedefs with an array require the array to have a size?
e.g. typedefunsignedlong Foo[3];
Or is this some sort of non-standard extension?
No warnings on pedantic. But pedantic also doesn't warn of VLAs, so I'm not totally convinced yet that it's legal.
Edit: I amend my statement -- cpp.sh doesn't show the VLA warning with int a = 3; int arr[a];,
but my desktop g++ compiler does.
The reason I am still not exactly convinced is that cppreference shows the unsized typedef in its C documentation, but not in its C++ documentation, leading me to believe it isn't allowed C++.
After all adjustments of types (during which typedefs (10.1.3) are replaced by their definitions), the types
specified by all declarations referring to a given variable or function shall be identical, except that declarations
for an array object can specify array types that differ by the presence or absence of a major array bound (11.3.4). A violation of this rule on type identity does not require a diagnostic.
And later on...
...if the constant expression is omitted, the type of the identifier of D is “derived-declarator-type-list array of unknown bound of T”, an incomplete object type.
So yes, it sounds like it's legal, but of course the type is incomplete, so it cannot be used in sizeof(Foo), for instance.
> if typedefs with an array require the array to have a size?
We can have a typedef (or type alias) for an incomplete type (array of unknown bound).
For example:
1 2 3 4 5 6 7 8 9 10 11
using a1_t = int[] ; // alias for array of unknown bound
externint a1[] ; // declaration of array of unknown bound
extern a1_t a11 ; // declaration of array of unknown bound
struct X ; // X is an incomplete type at this point
using a2_t = X[100] ; // alias for array of an incomplete type (known bound)
using a3_t = X[] ; // alias for array of unknown bound of an incomplete type
extern a2_t a21 ; //declaration array of an incomplete type (known bound)
extern X a2[] ; // declaration of array of unknown bound of an incomplete type