http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52377

             Bug #: 52377
           Summary: C++11 non-static initializers in unions are not used
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kenwayne...@hotmail.com


Created attachment 26748
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26748
command-line output and preprocessed file

Given the following code


#include <cstdio>

union Test
{
  int a{4};
};

int main()
{
  Test t;

  printf("%d", t.a);

  return 0;
}


the output is all junk data, unless I specify a -O option, in which case it
prints 0. Either way, t.a is not being properly initialized to 4.

Reply via email to