[Bug c++/54023] New: [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics

ebeworld at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jul 18 21:30:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54023

             Bug #: 54023
           Summary: [C++0x][initializer list] integer type to floating
                    type narrowing type is not producing diagnostics
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ebeworld@gmail.com


According to standard 8.5.4.7

A narrowing conversion is an implicit conversion...
-from an integer type or unscoped enumeration type to a floating-point type,
except where the source is a constant expression and the actual value after
conversion will fit into the target type and will produce the original value
when converted back to the original type, ...

and not allowed at top level. Therefore followings should be generate
diagnostics

int i=3;
double d=i;
float f=i;
long double ld=i;

char c=3;
double d=c;

etc.. should give narrowing error.



More information about the Gcc-bugs mailing list