This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52377] New: C++11 non-static initializers in unions are not used


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: unassigned@gcc.gnu.org
        ReportedBy: kenwaynevan@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]