Compiler Warning (level 1) C4269
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 1) C4269

Error Message

'identifier' : 'const' automatic data initialized with compiler generated default constructor produces unreliable results

A const automatic instance of a non-trivial class is initialized with a compiler-generated default constructor.


// C4269.cpp
// compile with: /c /LD /W1
class X {
   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.

© 2015 Microsoft