[Bug target/14788] [3.3/3.4/3.5 Regression] Subtracting a double from a short gives incorrect result
wilson at specifixinc dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 31 00:11:00 GMT 2004
------- Additional Comments From wilson at specifixinc dot com 2004-03-31 00:11 -------
Subject: Re: [3.3/3.4/3.5 Regression] Subtracting a double
from a short gives incorrect result
Not a bug.
The double subtract results in a value -35536.0 which exceeds the range
of short. So the result of the second subtraction depends on the
behaviour of converting an out-of-range value to a short, which is
undefined. So both gcc and the Sun compiler are correct here. Any
result is correct here. Gcc is converting the value to SHRT_MIN which
is the closest representable short value. The Sun compiler is perhaps
converting to int and then truncating to short which gives a wrapped
around result.
This is section 3.2.1.3 in the 1989 ANSI C standard, and section 6.3.1.4
in the 1999 ISO C standard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14788
More information about the Gcc-bugs
mailing list