Re: Is "T[N][]" (or "T[N][][M]") indirectly legal?
Am 18.09.2013 08:18, schrieb Daryle Walker:
I'm trying out stuff with GCC 4.7 via MinGW for 32-bit Windows 8. The stuff
I'm testing with involves array types with zero or unknown bounds (in C++11
mode).
* Playing the type combinations that give an array type with a bound of zero
work!
If you mean
T[]
or
T[][N]
with N > 0 this should be well-formed, yes.
With multidimensional arrays, the zero-extent can be at any place.
If so, this compiler would be buggy. According to 8.3.4 [dcl.array] p1:
"[..] T is called the array element type; this type shall not be a [..],
an array of unknown or runtime bound, [..]."
I'm a bit astonished of your observation, because I tested several
versions of gcc and none of them allowed such a type. Maybe you should
provide a concrete code example where this happens.
Their "sizeof" gives zero, and I can even make (non-zero) arrays of those
arrays (also having a zero sizeof).
This would be another compiler defect, because applying sizeof to an
incomplete type is ill-formed:
"The sizeof operator shall not be applied to an expression that has [..]
incomplete type, [..], to the parenthesized name of such types, [..]"
* Declaring an array type that has any extent as unbound besides the first
flags an error on my GCC 4.7 setup. But I can indirectly create arrays
with an unbound non-first extent via typedefs in recursive variadic class
templates. When I glanced at the Standard, it seemed to support banning
such array declarations directly, but indirect means didn't seem banned.
Are non-first unbound extents actually permitted or not? (If not, then
GCC 4.7 has a bug there, too.)
Again, please provide a concrete, short code example.
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]