[Bug ada/35194] New: floating point truncation error on intel platform
jerome dot duquennoy at wanadoo dot fr
gcc-bugzilla@gcc.gnu.org
Thu Feb 14 13:37:00 GMT 2008
In some situations (after a call to a C oracle function, or when running the
program on top of valgrind), floats behave strangely : a given, hard coded
float value displays erroneously.
For exemple, a float value of 1.2001 would print as "1.20831E+0".
Our analysis :
We reproduced the problem either using functions from the Oracle C library or
running the software on top of valgrind.
The tests were done on a Suse Linux 10.0 and a centos 5.1, using a 4.1.2
compiler and a 4.2.3 compiler, running on an intel-based machine (core2duo and
pentium D).
We COULD NOT reproduce the problem on a solaris 9 UltraSPARC III based machine.
Using a customized img_real package, we found that the bad behaving code is the
Long_Long_Float'Truncation attribute, called in the Convert_Integer procedure
of the Set_Image_Real procedure, in package img_real.
This function seems to be platform-dependent, this is coherent with the
behaviour difference between a sparc-based machine and an pentium-based one.
The problem can be reproduced easily by compiling this simple code, and running
the executable under Valgrind :
with
ada.text_io,
Ada.Strings.Fixed,
System.img_real;
use
Ada.Strings.Fixed,
ada.text_io,
System.img_real;
procedure test_fio is
value : Long_Long_Float;
resulting_string : string(1..15);
nat : natural;
begin
value := 1.2001;
resulting_string := (others => ' ');
nat := 0;
set_image_real(value, resulting_string, nat, 2, 4, 2);
put_line ("resulting_string : '" & resulting_string & "'");
end test_fio;
--
Summary: floating point truncation error on intel platform
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jerome dot duquennoy at wanadoo dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35194
More information about the Gcc-bugs
mailing list