This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52377] New: C++11 non-static initializers in unions are not used
- From: "kenwaynevan at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Feb 2012 23:21:51 +0000
- Subject: [Bug c++/52377] New: C++11 non-static initializers in unions are not used
- Auto-submitted: auto-generated
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.