[Bug ada/8925] Floating point code gives incorrect results

kalmquist1 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Sun Sep 14 22:43:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8925



------- Additional Comments From kalmquist1 at hotmail dot com  2003-09-14 22:22 -------
The basic problem appears to be a bug in handling of machine code insertions
by GNAT 3.2.

The code sumbitted with this bug report calls Ada.Numerics.Elementary_Func-
tions.Sin, which in turn calls Ada.Numerics.Aux.Sin.  The version of
Ada.Numerics.Aux.Sin used on the x86 platform contains a machine code
insertion.  The assembly language code produced by the compiler appears to
be correct until we get to the following:

#APP
	fsin                 
	xorl    %eax, %eax 
	fnstsw  %ax
#NO_APP
	fstp	%st(0)

The fstp instruction discards the sin value computed by the fsin instruction.
Skipping to the end of the routine, we see:

	fldt	-40(%ebp)
	leave
	ret

This returns the floating point value stored at -40(%ebp), but no value has
been stored at that location by this routine, so the returned value is whatever
garbage happened to be stored in that memory location before the routine was
called.

Similar code written in C is compiled correctly, so the problem appears to
be GNAT specific.

Based on additional comments numbers 12 and 13, it appears that the problem
has been fixed in more recent versions of GNAT, so the status of this bug
should probably be changed to FIXED.  I haven't done that because I haven't
installed the more recent versions and thus cannot confirm the fix.



More information about the Gcc-bugs mailing list