Does `int a = 0, b = a` have undefined behavior?

c++, declaration, undefined-behavior

Solution

No, this is well-defined. This is a declaration with two declarators, `a` and `b`. Each declarator has an initializer.

Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself.

That is, the line is treated like:

int a = 0;
int b = a;

Problem

The question title says it all: do declarations of the form `int a = 0, b = a` have undefined behavior?

Original source

Related problems