This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54023] New: [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics
- From: "ebeworld at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Jul 2012 21:28:45 +0000
- Subject: [Bug c++/54023] New: [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics
- Auto-submitted: auto-generated
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.