In article <news:clpci2$hkg$>
Peter Ammon <> wrote:
>... checking the standard, it appears that commas are indeed forbidden
>from being in a constant expression.
>
>Why's that? Wouldn't it make more sense to allow commas as long as the
>left and right operands are also constant expressions? Calling the
>expression 1,9 "variable-size" is pretty silly.
Asking for sense from the Standards Committees may be going a bit
overboard.
Seriously, even if the left operand is *not* constant, the
expression itself could still be a constant. For instance:
i = (printf("hello\n"), 2);
is certain to set i to 2. In this case, however, there is also
a required side-effect (writing "hello\n" to stdout). As such,
the parenthesized expression is clearly unsuitable for use as a
static initializer:
static int x = (printf("hello\n"), 2); /* WRONG */
but might be allowed as a constant in "more general" positions:
printf("I say ");
{
int i, x[(printf("hello\n"), 2)];
for (i = 0; i < sizeof x / sizeof *x; i++)
x[i] = printf("Hello hello\n");
printf("I don't know why you say goodbye\n");
printf("I say hello\n");
}
So perhaps, once one starts down this road, a committee subgroup
might not be able to agree as to precisely what is allowed when.

--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.