L
Luca Forlizzi
The declaration part of a for statement is subject to the constraint
given in
Sec. 6.8.5 p3, which says "The declaration part of a for statement
shall only declare identifiers for objects having
storage class auto or register."
DR 277 clarifies that this constraint is violated if the declaration
declare an identifier that
is not an object, like a tag or an enumeration constant.
To me (as a non-native english speaker) it is not clear if the
constraint is violated
in the case where the declaration declares a new type without a tag
(if the new
type has a tag, then it clearly violates the constraint because the
tag is an
identifier not denoting an object), like for instance in:
for (struct { short a[2]; float b; } d = { {0, 0}, 0 }; d.b<10.5; d.b+
+) ...
I notice that gcc silently accept this construct, while producing
diagnostics in
cases where is present an identifier not denoting an object with auto
or register
storage class.
Is gcc right?
given in
Sec. 6.8.5 p3, which says "The declaration part of a for statement
shall only declare identifiers for objects having
storage class auto or register."
DR 277 clarifies that this constraint is violated if the declaration
declare an identifier that
is not an object, like a tag or an enumeration constant.
To me (as a non-native english speaker) it is not clear if the
constraint is violated
in the case where the declaration declares a new type without a tag
(if the new
type has a tag, then it clearly violates the constraint because the
tag is an
identifier not denoting an object), like for instance in:
for (struct { short a[2]; float b; } d = { {0, 0}, 0 }; d.b<10.5; d.b+
+) ...
I notice that gcc silently accept this construct, while producing
diagnostics in
cases where is present an identifier not denoting an object with auto
or register
storage class.
Is gcc right?