Pelles C forum
Pelles C => Bug reports => Topic started by: aj on June 20, 2009, 04:50:37 PM
-
char *txt[1] = {
[0] "asdf",
};
This works in Pelles C - should it?
-
char *txt[1] = {
[0] "asdf",
};
This works in Pelles C - should it?
I would say YES! ;)
You define an array of strings with one member and this member points to "asdf". :)
-
it souldn't.
at least, = operator is missing :
char *txt[1] = {
[0] = "asdf",
};
but better is
char const *txt[] = {
[0] = "asdf",
};
Let's look the standard:
6.7.8 Initialization
Syntax
1 initializer:
assignment-expression
{ initializer-list }
{ initializer-list ,}
initializer-list:
designationopt initializer
initializer-list , designationopt initializer
designation:
designator-list =
designator-list:
designator
designator-list designator
designator:
[ constant-expression ]
. identifier
-
Right now the compiler will no insist on the missing '=' (IIRC for compatibility reasons), but a warning should be issued (in standard mode at least).