Compiler Warning (level 3) C4608
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 3) C4608

Error Message

'union_member' has already been initialized by another union member in the initializer list, 'union_member'

Two members of the same union were initialized in an initialization list. You can only access one member of the union.

The following sample generates C4608:

// C4608.cpp
// compile with: /W3 /c
class X {
   X(char c) : m_i( c + 1), m_c(c) {}   // C4608
   // try the following line instead
   // X(char c) : m_c(c) {}

   union {
      int m_i;
      char m_c;

union Y {
   Y(char * name) : m_number(0.3), m_string( name ) {} // C4608

   double m_number;
   char * m_string;
© 2015 Microsoft