This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Incorrect runtime behavior involving comparison
- To: Matt Austern <austern at isolde dot engr dot sgi dot com>
- Subject: Re: Incorrect runtime behavior involving comparison
- From: Steve <moshier at dsp dot sls dot com>
- Date: Mon, 10 Jan 2000 21:30:38 -0500 (EST)
- cc: gcc-bugs at gcc dot gnu dot org
> bool t1 = z1.priority() > z2.priority();
> bool t2 = z2.priority() > z1.priority();
This fails on i386 because of the so-called extra-precise fpu register
effect. It is a feature, not a bug.
If you look at the generated assembly language
call priority__4zone
addl $16,%esp
fstpl -40(%ebp)
addl $-12,%esp
leal -8(%ebp),%eax
pushl %eax
call priority__4zone
addl $16,%esp
fcompl -40(%ebp)
you see that one result is stored out to memory and gets rounded off
from the extended register precision to double precision. The
other result is not stored; it remains in the fpu register as an
extra-precise value during the compare.
The program succeeds if you set the i386 math coprocessor to double
precision mode. Some systems, such as Microsoft Windows, do that by
default, but in doing so they throw away the extended precision long
double data type.