[Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 13 17:36:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list