Reading an uninitialized object that is not backed by memory
suggest changeReading an object has undefined behavior when all of the following are true1:
- it is uninitialized
- it has automatic storage duration
- its address is never taken
The variable a in the below example satisfies all those conditions:
void Function( void )
{
int a;
int b = a;
}
1 (Quoted from: ISO/IEC 9899:201x, 6.3.2.1, paragraph 2)
If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents