C
CBFalconer
Keith said:CBFalconer said:Keith Thompson wrote:
... snip ...In fact, the implementations I've seen do reject it (i.e., issue
a diagnostic and fail to process the translation unit), and I
believe that's the only reasonable behavior. But I don't see how
to justify it based on the normative wording of the standard.
See my earlier answer, which was:
How about this. No exceptions are mentioned, thus it covers all.
6.5.3.4 The sizeof operator
... snip ...
Semantics
[#2] The sizeof operator yields the size (in bytes) of its
operand, which may be an expression or the parenthesized
name of a type. The size is determined from the type of the
operand. The result is an integer. If the type of the
operand is a variable length array type, the operand is
evaluated; otherwise, the operand is not evaluated and the
result is an integer constant.
How does this address my point?
Given the expression:
sizeof (char[SIZE_MAX][2])
the quoted definition for sizeof doesn't imply a constraint
violation or other error. It implies a contradiction *in the
standard*.
sizeof measures the size of objects, or the type definition that
will be used in constructing an object. Notice the first sentence
of para. 4 below.
6.2.4 Storage durations of objects
.... snip ...
[#4] For such an object that does not have a variable length |
array type, storage is guaranteed to be reserved for a new
instance of the object on each entry into the block with
which it is associated; the initial value of the object is
indeterminate. If an initialization is specified for the
object, it is performed each time the declaration is reached
in the execution of the block; otherwise, the value becomes
indeterminate each time the declaration is reached. Storage
for the object is no longer guaranteed to be reserved when
execution of the block ends in any way. (Entering an
enclosed block or calling a function suspends, but does not
end, execution of the current block.)