no warning when assigning an unsigned int to signed double

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Mon Jun 2 09:32:00 GMT 2003


Zhang Le <ejoy@xinhuanet.com> writes:

>     I'm not sure if this is a bug:
>     ============
>     size_t i = 3;
>     double d;
>     d = -i;
>     cout << d << endl;
>     ============
>     compile is ok without any warning with -Wall flag.
> 
>     and I get:4.29497e+09
> 
>     But what I want is -3
> 
>     Clearly here gcc should generate a warning message when assigning an
>     unsigned int to signed double.

That assignment is not the problem; you get the same result when
declaring d as size_t. Negating an unsigned value is.

-- 
	Falk



More information about the Gcc-bugs mailing list