This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49577] New: [C++0x] narrowing conversion not rejected
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 29 Jun 2011 12:37:45 +0000
- Subject: [Bug c++/49577] New: [C++0x] narrowing conversion not rejected
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
CC: jason@gcc.gnu.org
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 };