unsigned / double propagation weirdness?
Robert Dewar
dewar@gnat.com
Mon Feb 23 16:56:00 GMT 2004
Andrew Pinski wrote:
> The reason is that -i*dm really is (-i)*dm which is really
> ((double)(-i))*dm.
>
> So it turns out to be ((unsigned int)-1) * 1.0 which is different from
> -(double)(1) * 1.0.
> So it just misunderstanding on where the unary operator, -, applies to
> and when the cast
> happens.
Indeed. I would be interested in exactly what warning is being proposed,
since you certainly don't want to regard the use of unary minus on
unsigned as something you warn about. Basically this error is one of
precedence, and I have a hard time seeing what warning might reasonably
be generated in this case.
More information about the Gcc
mailing list