clang and EDG reject the following code (GCC accepts it),
struct {
char control[((int)(char *)2)];
} xx;
What about your cfe?
Thanks,
snaroff
clang and EDG reject the following code (GCC accepts it),
struct {
char control[((int)(char *)2)];
} xx;
What about your cfe?
Thanks,
snaroff
I just noticed that GCC does complain if the "char *" is the topmost cast.
[steve-naroffs-imac:llvm/tools/clang] snaroff% ../../Debug/bin/clang ary.c
ary.c:3:16: error: size of array has non-integer type 'char *'
char control[(char *)2];
^~~~~~~~~
Looks like it could be a GCC bug related to how it does constant folding...
snaroff
I just noticed that GCC does complain if the "char *" is the topmost
cast.[steve-naroffs-imac:llvm/tools/clang] snaroff% ../../Debug/bin/clang
ary.c
ary.c:3:16: error: size of array has non-integer type 'char *'
char control[(char *)2];
^~~~~~~~~
This isn't legal simply because the size of an array must have an
integer type. This doesn't say anything useful.
struct {
char control[((int)(char *)2)];
} xx;
"Cast operators in an integer constant expression shall only convert
arithmetic types to integer types", so (int)(char*)2 is not an ICE.
Therefore, the declarator declares a variable length array, and since
struct members aren't allowed to have a variably modified type, this
is illegal.
This was already discussed recently; see
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001771.html.
-Eli