This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/49577] New: [C++0x] narrowing conversion not rejected


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 };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]