J
Jeremy Yallop
Dan said:It's another C99 feature, but it is not needed here. Without static,
things would be even simpler:
int main(int argc, char *argv[printf("Hello World\n")]) {}
because the value used in the VLA definition is completely ignored after
being evaluated for any side effects, the effective type of argv being
char **, as usual.
I couldn't find where the standard says the expression is evaluated
for side effects, which is why I added the 'static' (which clearly
requires evaluation of the expression). I took the following to mean
that the expression is not evaluated:
5 If the size is an expression that is not an integer constant
expression: if it occurs in a declaration at function prototype
scope, it is treated as if it were replaced by *; otherwise, each
time it is evaluated it shall have a value greater than zero.
Jeremy.