[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#532871: g++-4.4: No warning about value-altering conversion inspite of -Wconversion and -Wsign-conversion



tags 532871 + moreinfo
thanks

On Fri, Jun 12, 2009 at 01:20:54PM +0200, Sven Marnach wrote:
> The following program compiles cleanly using the given command line:
> 
>     #include <iostream>
>     using namespace std;
>     int main()
>     {
>         unsigned int j = 5;
>         double t;
>         t = -j;
>         cout << t << endl;
>     }
> 
> Command line:
> 
>     g++-4.4 -g -Wall -Wextra -Wconversion -Wsign-conversion test.cc -o test
> 
> The output of the program is
> 
>     4.29497e+09
> 
> which is what is expected.  But I would also expect some kind of
> warning.

The result of "-j" is the unsigned value 4294967291, which can be
losslessly represented in a double. So why do you expect a warning?

  Falk



Reply to: