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++/55077] implement and enable by default -Wliteral-conversion


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55077

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #7 from Eric Gallager <egallager at gcc dot gnu.org> ---
Combining the 2 testcases from this bug, I get the following output now:

$ $ cat 55077.c && /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Wconversion
-Wdouble-promotion 55077.c 
static const int c = 3.1415926;
int x = 24 * 0.5;
int y = (24*60*60) * 0.25;
int pennies = 123.45 * 100;
55077.c:1:22: warning: conversion from 'double' to 'int' changes value from
'3.1415926000000001e+0' to '3' [-Wfloat-conversion]
 static const int c = 3.1415926;
                      ^~~~~~~~~
55077.c:1:18: warning: 'c' defined but not used [-Wunused-const-variable=]
 static const int c = 3.1415926;
                  ^
$

So it shows the values before/after now; still might want to split off a
separate -Wliteral-conversion flag though.

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