Both g++ and clang++ compile this snippet:
typedef int int3[];
int3 i { 0, 1, 2 };
But where in the standard does it say that the array typedef declaration above is valid?
How do you infer that int3[] is a "synonym" for int[]?
Both g++ and clang++ compile this snippet:
typedef int int3[];
int3 i { 0, 1, 2 };
But where in the standard does it say that the array typedef declaration above is valid?
How do you infer that int3[] is a "synonym" for int[]?
But where in the standard does it say that the typedef declaration above is valid?
It's valid. As per the standard:
1 - Declarations containing the decl-specifier typedef declare identifiers that can be used later for naming fundamental (6.8.2) or compound (6.8.3) types. [...]
Where:
1 - Compound types can be constructed in the following ways:
— (1.1) arrays of objects of a given type, 9.3.4.5;
[...]
How do you infer that
int3[]is a "synonym" forint[]?
The declaration is well defined, including for arrays with unknown bounds:
[...]
5 - Any type of the form “cv-qualifier-seq array of N U” is adjusted to “array of N cv-qualifier-seq U”, and similarly for “array of unknown bound of U”.
[...]