Possible Duplicate:
Is the comma in a variable list a sequence point?
If I have the following code does the comma act as a normal sequence point, or is the behaviour undefined?
int i = 1, j = i;
I don't actually plan to use this (our internal standard prohibits even int i, j
) but I was curious and it prooved oddly tricky to google.
It's well-defined:
3) Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself.
And the note:
90) A declaration with several declarators is usually equivalent to the corresponding sequence of declarations each with a single declarator. That is
T D1, D2, ... Dn;
is usually equvalent to
T D1; T D2; ... T Dn;
where T is a decl-specifier-seq and each Di is an init-declarator.
For completness (because the note says usually):
The exception occurs when a name introduced by one of the declarators hides a type name used by the dcl-specifiers, so that when the same dcl-specifiers are used in a subsequent declaration, they do not have the same meaning, as in
struct S { ... }; S S, T;
// declare two instances of struct Swhich is not equivalent to
struct S { ... }; S S; S T; // error`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With