http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49577
Summary: [C++0x] narrowing conversion not rejected
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
unsigned u{ -1 };
char c = char{ u };
I believe this should be rejected because char{u} is a narrowing conversion and
the FDIS says in [dcl.init.list]/3:
- Otherwise, if the initializer list has a single element, the object or
reference is initialized from that element; if a narrowing conversion (see
below) is required to convert the element to T, the program is ill-formed.
These are correctly rejected:
char c1{ u };
char c2 = { u };
char* p = new char{ u };