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++/54023] New: [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics


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.


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