Bug 19174 - [4.0 Regression] wrong code regression or library problem in gcc-4.0-20041226
Summary: [4.0 Regression] wrong code regression or library problem in gcc-4.0-20041226
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: regression (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on: 19511
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-28 13:02 UTC by andre.maute
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andre.maute 2004-12-28 13:02:34 UTC
consider the following code snippet 
 
-------- nan.cc ------- 
#include <iostream> 
int main() { 
        double x = 0.55555555555555558023; 
        std::cout << x << " "; 
        std::cout << x << " "; 
        std::cout << std::endl; 
        return 0; 
} 
-------- nan.cc ------- 
 
> g++-4.0-20041226 -v 
Using built-in specs. 
Configured with: ../gcc-4.0-20041226/configure --prefix=/opt/gcc-4.0-20041226 
--enable-shared --enable-languages=c,c++ --enable-threads=posix 
--enable-__cxa_atexit --enable-clocale=gnu --disable-nls 
--program-suffix=-4.0-20041226 --with-arch=pentium3 --disable-checking 
Thread model: posix 
gcc version 4.0.0 20041226 (experimental) 
 
> g++-4.0-20041226 nan.cc 
> ldd a.out 
       libstdc++.so.6 => /opt/gcc-4.0-20041226/lib/libstdc++.so.6 (0x40017000) 
       libm.so.6 => /lib/libm.so.6 (0x400fc000) 
       libgcc_s.so.1 => /opt/gcc-4.0-20041226/lib/libgcc_s.so.1 (0x4011f000) 
       libc.so.6 => /lib/libc.so.6 (0x40129000) 
       /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) 
> ./a.out 
0.555556 nan 
 
well this nan shouldn't be there 
 
> g++-4.0-20041226 nan.cc -static 
 
> ./a.out 
0.555556 0.555556 
 
> g++-4.0-20041212 -v 
Reading specs from /opt/gcc-4.0-20041212/lib/gcc/i686-pc-linux-gnu/4.0.0/specs 
Configured with: ../gcc-4.0-20041212/configure --prefix=/opt/gcc-4.0-20041212 
--enable-shared --enable-languages=c,c++ --enable-threads=posix 
--enable-__cxa_atexit --enable-clocale=gnu --disable-nls 
--program-suffix=-4.0-20041212 --with-arch=pentium3 --disable-checking 
Thread model: posix 
gcc version 4.0.0 20041212 (experimental) 
 
> g++-4.0-20041212 nan.cc 
> ldd ./a.out 
       libstdc++.so.6 => /opt/gcc-4.0-20041212/lib/libstdc++.so.6 (0x40017000) 
       libm.so.6 => /lib/libm.so.6 (0x400fb000) 
       libgcc_s.so.1 => /opt/gcc-4.0-20041212/lib/libgcc_s.so.1 (0x4011e000) 
       libc.so.6 => /lib/libc.so.6 (0x40128000) 
       /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) 
 
> ./a.out 
0.555556 0.555556 
 
g++-4.0-20041212 doesn't have this problem
Comment 1 Andrew Pinski 2004-12-28 14:29:31 UTC
I cannot reproduce this on powerpc-darwin.
Comment 2 andre.maute 2004-12-28 17:21:28 UTC
Oh i forgot my system triplets, they are all 
i686-pc-linux-gnu 
 
g++-4.0-20041226 -v 
doesn't show the triplet any more, there is only a line 
 
Using built-in specs. 
 
i suggest to remove this new feature for convenience. 
Comment 3 andre.maute 2004-12-28 18:03:26 UTC
it looks like it is really a library problem. Using the libraries from 
gcc-4.0-20041212 
everything is fine, although nan.cc was nevertheless compiled with 
gcc-4.0-20041226. 
 
> ldd a.out 
       libstdc++.so.6 => /opt/gcc-4.0-20041212/lib/libstdc++.so.6 (0x40017000) 
       libm.so.6 => /lib/libm.so.6 (0x400fb000) 
       libgcc_s.so.1 => /opt/gcc-4.0-20041212/lib/libgcc_s.so.1 (0x4011e000) 
       libc.so.6 => /lib/libc.so.6 (0x40128000) 
       /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) 
> ./a.out 
0.555556 0.555556 
 
Comment 4 Richard Henderson 2004-12-29 00:42:00 UTC
I don't reproduce this with a build from last night.

Try again with today's sources.  In particular, the symptom looks as if the
fpu has been put into mmx mode.  Which might be solved with

2004-12-27  Richard Henderson  <rth@redhat.com>

        * config/i386/i386.h (UNITS_PER_SIMD_WORD): Don't use MMX/3DNOW.

2004-12-26  Richard Henderson  <rth@redhat.com>

        * config/i386/i386.md (mov<MMXMODEI>_internal_rex64): New.
        (movv2sf_internal_rex64): New.
        (mov<MMXMODEI>_internal): Use no register preferences at all.
        (movv2sf_internal): Likewise.
Comment 5 andre.maute 2004-12-29 11:14:41 UTC
Sorry no cvs available, and only a modem dial-up connection, 
i'll try it when the new snapshot diff is available. 
 
Comment 6 andre.maute 2005-01-01 23:58:13 UTC
if i remove the architecture option from the configure parameters 
 
> g++-4.0-20041226-na -v 
Using built-in specs. 
Configured with: ../gcc-4.0-20041226/configure 
--prefix=/opt/gcc-4.0-20041226-na--enable-shared --enable-languages=c,c++ 
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu 
--disable-nls --program-suffix=-4.0-20041226-na --disable-checking 
Thread model: posix 
gcc version 4.0.0 20041226 (experimental) 
 
> g++-4.0-20041226-na nan.cc 
> ./a.out  
0.555556 0.555556  
 
> g++-4.0-20041226-na nan.cc -march=pentium3 
> ./a.out  
0.555556 0.555556 
 
is this mysterious? because now everything looks o.k. 
for compilation of gcc-4.0-20041226 i used gcc-4.0-20041212. 
 
Comment 7 andre.maute 2005-01-02 21:06:52 UTC
well i've tested gcc-4.0-20050102, (compiled with gcc-4.0-20041212) 
 
> g++-4.0-20050102 -v 
Using built-in specs. 
Configured with: ../gcc-4.0-20050102/configure --prefix=/opt/gcc-4.0-20050102 
--enable-shared --enable-languages=c,c++ --enable-threads=posix 
--enable-__cxa_atexit --enable-clocale=gnu --disable-nls 
--program-suffix=-4.0-20050102 --with-arch=pentium3 --disable-checking 
Thread model: posix 
gcc version 4.0.0 20050102 (experimental) 
 
> g++-4.0-20050102 nan.cc 
> ./a.out 
0.555556 nan 
 
the problem is still there 
Comment 8 andre.maute 2005-01-02 23:44:21 UTC
the C-version works with every compiler 
 
------------ nan.c ----------- 
#include <stdio.h> 
int main() { 
        double x = 0.55555555555555558023; 
        printf( "%f ", x ); 
        printf( "%f ", x ); 
        printf( "\n" ); 
        return 0; 
} 
------------ nan.c ----------- 
 
Comment 9 Richard Henderson 2005-01-04 00:03:31 UTC
I'm willing to lay money this is the same problem as PR 19235.

*** This bug has been marked as a duplicate of 19235 ***
Comment 10 andre.maute 2005-01-04 17:46:35 UTC
tried gcc-4.0-20050102 with the patch    
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.597&r2=1.598   
from   
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19235   
   
and the problem still does occur :-( 
 
P.S.: compiled with gcc-4.0-20041212 
Comment 11 andre.maute 2005-01-10 00:00:16 UTC
tried gcc-4.0-20050109 compile with gcc-3.4.3 
the problem still appears 
Comment 12 andre.maute 2005-01-17 12:28:03 UTC
gcc-4.0-20050116 compiled with gcc-3.3.5 this time 
 
with the configure parameter: --with-arch=pentium3 
fails 
 
withOUT the configure parameter: --with-arch=pentium3 
everything is o.k. 
 
with respect to the library things i mentionend, is it possible that 
libstdc++.so 
is miscompiled, when the above configure parameter is used.? 
Comment 13 Richard Henderson 2005-01-19 21:21:55 UTC
Yes, it's certainly possible.  But indeed pr19511 shows that you can't even get
that far with --with-arch=pentium3 at the moment, due to changes that post-date
this report.

After I get a fix for that problem, will you please re-test?  Hopefully I'll 
have magically fixed this problem which was never sufficiently isolated...
Comment 14 andre.maute 2005-01-24 10:42:16 UTC
It looks like it is fixed now 
 
Compiling gcc-4.0-20050123 with a gcc-4.0-20050116, which has the architecture 
option disabled, works. Great! 
 
Regards Andre 
Comment 15 Andrew Pinski 2005-01-24 13:29:58 UTC
Fixed so lets close it.