This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: no warning when assigning an unsigned int to signed double
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Zhang Le <ejoy at xinhuanet dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 02 Jun 2003 11:32:28 +0200
- Subject: Re: no warning when assigning an unsigned int to signed double
- References: <mutt.200306021541.49@peoplemail.com.cn>
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