Does the following invoke undefined behavior?
int x;
int i = x;
Reference from C++03
(4.1/1) If the object to which the lvalue refers is not an object of type T
and is not an object of a type derived from T, or if the object is
uninitialized, a program that necessitates this conversion has
undefined behavior.
Edit:
However, from (3.3.1/1) an object may be initialized with its own indetermine value, why is that? i.e.
int x = x; //not an undefined behaviour
Yes, because you’re reading the value of a variable (
x) which was uninitialised and unassigned.