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]

Re: no warning when assigning an unsigned int to signed double


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


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