Reading an uninitialized object that is not backed by memory
suggest changeReading an object will cause undefined behavior, if the object is1:
- uninitialized
- defined with automatic storage duration
- it’s 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 Lvalues, arrays, and function designators 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