This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 13 Oct 2012 17:36:25 +0000
- Subject: [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922
Bug #: 54922
Summary: [C++11][DR 1359] constexpr constructors require
initialization of all union members
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
gcc 4.8.0 20120930 (experimental) compiled with the flags
-Wall -pedantic -std=c++11
rejects the following code:
//----------------
lass nullable_int
{
bool init_;
union {
unsigned char for_value_init;
int value_;
};
public:
constexpr nullable_int() : init_(false), for_value_init() {}
};
//----------------
"main.cpp||In constructor 'constexpr nullable_int::nullable_int()':|
main.cpp|9|error: uninitialized member 'nullable_int::<anonymous>' in
'constexpr' constructor|"
This prevents a very reasonable use-case, namely the creation of a literal type
that contains an anonymous union member.