Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'identifier' : 'const' automatic data initialized with compiler generated default constructor produces unreliable results
Remarks
A const automatic instance of a non-trivial class is initialized with a compiler-generated default constructor.
Example
The following example generates C4269:
// C4269.cpp
// compile with: /c /LD /W1
class X {
public:
int m_data;
};
void g() {
const X x1; // C4269
}
Since this instance of the class is generated on the stack, the initial value of m_data can be anything. Also, since it is a const instance, the value of m_data can never be changed.