http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57342
Bug ID: 57342 Summary: [C++11] Warning for narrowing conversion has ugly formatting for floating point number Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: austern at google dot com When I compile the following code void foo() { int pi{3.14}; }; I get the following output: [isolde:tmp]$ ~/root/bin/g++ -c -std=c++11 foo.cc foo.cc: In function ‘void foo()’: foo.cc:2:14: warning: narrowing conversion of ‘3.1400000000000001e+0’ from ‘double’ to ‘int’ inside { } [-Wnarrowing] int pi{3.14}; ^ The warning is of course correct. (Arguably it ought to be an error instead of just a warning, but I won't quibble. The standard requires a diagnostic and we're getting a diagnostic.) I'm filing this bug because I expect to see "narrowing conversion of ‘3.14' from 'double' to 'int'", as opposed to "narrowing conversion of ‘3.1400000000000001e+0' from 'double' to 'int'". Yes, I'm sure the two forms are equivalent within the precision we're using, but one form is human-friendly and the other isn't. Configuration: [isolde:tmp]$ ~/root/bin/g++ -v Using built-in specs. COLLECT_GCC=/usr/local/google/home/austern/root/bin/g++ COLLECT_LTO_WRAPPER=/usr/local/google/home/austern/root/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc/configure --prefix=/usr/local/google/home/austern/root --enable-languages=c++ Thread model: posix gcc version 4.9.0 20130520 (experimental) (GCC) [isolde:tmp]$