Peter Nilsson said:
Le 28/05/11 21:28, Bill Cunningham a @C3{A9}crit :
double a[] = 2.2, 4.2, 5.00;
...
p.c: In function `main':
p.c:12: invalid initializer
p.c:12: parse error before numeric constant
...lcc-win issued NO ERRORS AT ALL.
Even if you claimed conformance, it's not required to. It
follows the context free grammar. [snip]
Sure looks like a syntax error to me. You have a
derivation to offer?
I also think it's a syntax error, but take a look at this more subtle case:
int i=1, j=2;
int main(void)
{
int a[] = i, j;
}
It's invalid because the array initializer doesn't have braces. But that's
not a requirement of the grammar. In n1256.pdf, the clause that it violates
is 6.7.8.16, under the heading of "Semantics", not "Constraints".
And it can be made valid by putting braces around just the i, which makes a
single-element a[] and a local j shadowing the global j:
int a[] = {i}, j;
or by putting braces around both, making a 2-element a[]:
int a[] = {i, j};
A compiler that accepts the form without braces must be choosing one of those
interpretations. Which one?