This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Gcc 4.2 miscompiles binutils on x86 and x86-64
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: R Hill <dirtyepic dot sk at gmail dot com>, Nick Clifton <nickc at redhat dot com>, binutils at sources dot redhat dot com, gcc at gcc dot gnu dot org
- Date: Sat, 29 Apr 2006 16:54:15 -0700
- Subject: Gcc 4.2 miscompiles binutils on x86 and x86-64
- References: <or4q2gsou6.fsf@free.oliva.athome.lsd.ic.unicamp.br> <20060302183313.GB29439@lucon.org> <orzmk8r8jl.fsf@free.oliva.athome.lsd.ic.unicamp.br> <44081538.7070304@redhat.com> <4453042B.3040005@gmail.com> <20060429145053.GA3225@lucon.org> <or3bfwushl.fsf@free.oliva.athome.lsd.ic.unicamp.br>
On Sat, Apr 29, 2006 at 03:49:42PM -0300, Alexandre Oliva wrote:
> On Apr 29, 2006, "H. J. Lu" <hjl@lucon.org> wrote:
>
> > On Sat, Apr 29, 2006 at 12:14:03AM -0600, R Hill wrote:
> >>
> >> Testcase is:
> >>
> >> .tfloat 1.442695040888963407359924681002
> >>
> >> Binutils is 2.16.92, configured with:
> >>
>
> > It works for me with binutils in CVS and the Linux binutils
> > 2.16.91.0.7. Does the Linux binutils 2.16.91.0.7 work for you?
>
> H.J., we've gone through this before. You didn't use GCC trunk to
> build binutils, which is what triggers the bug.
>
It looks like a gcc bug to me. Gcc 4.2 miscompiles:
more_than_enough_bits_for_digits
= (number_of_digits_to_use * 3321928 / 1000000 + 1);
in atof_generic. When number_of_digits_to_use == 1, gcc 4.2 -O2 gets
more_than_enough_bits_for_digits as 4. The correct value is 37. I
am checking in this patch to warn users.
H.J.
----
2006-04-29 H.J. Lu <hongjiu.lu@intel.com>
* gas/i386/fp.d: New file.
* gas/i386/fp.s: Likewise.
* gas/i386/i386.exp: Run "fp".
--- gas/testsuite/gas/i386/fp.d.fp 2006-04-29 15:39:27.000000000 -0700
+++ gas/testsuite/gas/i386/fp.d 2006-04-29 15:55:50.000000000 -0700
@@ -0,0 +1,8 @@
+#objdump: -s -j .data
+#name: i386 fp
+
+.*: file format .*
+
+Contents of section .data:
+ 0000 00881bcd 4b789ad4 004071a3 79094f93 ....Kx...@q.y.O.
+ 0010 0a40789a 5440789a 54400000 00000000 .@x.T@x.T@......
--- gas/testsuite/gas/i386/fp.s.fp 2006-04-29 15:39:23.000000000 -0700
+++ gas/testsuite/gas/i386/fp.s 2006-04-29 15:59:52.000000000 -0700
@@ -0,0 +1,13 @@
+ .data
+# .tfloat is 80-bit floating point format.
+ .tfloat 3.32192809488736218171e0
+# .byte 0x0, 0x88, 0x1b, 0xcd, 0x4b, 0x78, 0x9a, 0xd4, 0x0, 0x40
+# .double is 64-bit floating point format.
+ .double 3.32192809488736218171e0
+# .byte 0x71, 0xa3, 0x79, 0x09, 0x4f, 0x93, 0x0a, 0x40
+# The next two are 32-bit floating point format.
+ .float 3.32192809488736218171e0
+# .byte 0x78, 0x9a, 0x54, 0x40, 0, 0, 0, 0
+ .single 3.32192809488736218171e0
+# .byte 0x78, 0x9a, 0x54, 0x40, 0, 0, 0, 0
+ .byte 0, 0, 0, 0, 0, 0
--- gas/testsuite/gas/i386/i386.exp.fp 2006-03-07 15:40:19.000000000 -0800
+++ gas/testsuite/gas/i386/i386.exp 2006-04-29 15:40:01.000000000 -0700
@@ -71,6 +71,7 @@ if [expr ([istarget "i*86-*-*"] || [ist
run_dump_test "merom"
run_dump_test "rep"
run_dump_test "rep-suffix"
+ run_dump_test "fp"
# These tests require support for 8 and 16 bit relocs,
# so we only run them for ELF and COFF targets.