Peter 'Shaggy' Haywood said:
Groovy hepcat Charlie Gordon was jivin' in comp.lang.c on Tue, 18 Sep
2007 9:36 pm. It's a cool scene! Dig it. [...]
Actually the moral should be that the Standard has a defect.
Evaluating the argument in not needed to determine the size of the VLA
object, so why should it be mandated ?
Actually, a VLA operand may need to be evaluated since the size is not
hard-wired and may not even be known to the compiler. For example, the
size may be determined by user input. An implementation may somehow
store the size of the VLA with the VLA. It would have to evaluate the
VLA in order to fetch the size information.
If the operand is an expression, I don't believe it's ever necessary
to evaluate the expression itself in order to determine the size of
the expression (i.e., the size of its type). The type of an
expression is determined at compilation time, even if that type is
variably-modified.
For example, given 'int vla[n];', determining 'sizeof vla' requires
knowing the value of 'n' (actually, the value that 'n' had when the
declaration was processed at run time), but it *doesn't* require
evaluating 'vla' itself. Evaluating 'vla' (in this context, in which
it's not converted to a pointer) would involve evaluating each of its
elements to determine their current values. This is not necessary, or
even useful, in determining 'sizeof vla'.
It is perfectly clear what evaluation means: determining the value of
(the expression), performing side effects and evaluating all
sub-expressions.
But the thing being "evaluated" isn't an expression; it's a type. As
far as I know, the standard doesn't talk about evaluating types,
except indirectly in this one case. It would be easy enough to
define; it requires evaluating each full expression that appears
within the type-name. (We need to specify full expressions, not each
subexpression, because a subexpression could be a
non-variably-modified argument to another sizeof operator.)
[...]