[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#216616: gcc-3.2: floating point problem with athlon thunderbird



Package: gcc-3.2
Version: 1:3.2.3-8
Severity: normal

I am not used to go this deep in code, i would appreciate any critisicm
regarding this report and the time you use on it.i If you think this
have nothing to do with gcc , i d be happy with this being reassigned to
the proper maintenair.

Is it ok that double operators give diferents results with athlon
TB than with other processors ?

Following some mozilla debugging i ended on a "if (10*double)" test in a
while statement.
The test work with the same binary under Athlon XP/Pentium porcessors but not with Athlon Thunderbird.

I isolated the whole conditional test in a file:
   mozjstest.c: the bad behaviour appear for testlimit >=5
  using print or a temporary variable round the d value correctly and
  fix the problem, i found out the wrong values with gdb print.

  to have the bug as in mozilla i multiplied d by 10 (as the mozilla
  code do)  , then even print is not able to round d value correctly 
  (why on athlon TB only ?).

extract from the real mozilla code (cf bug #203100):
d, ds are double; L a long
  L = (Long) (d / ds);
  d -= L*ds;
  on athlon  "d - d != 0"  (especially d -= L*ds) though it is on other
  processors (still same binary)
  
  the loop is ended by:
  if (!(d *= 10.))
    break;
  and d never equals 0 


Alban

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux argos 2.6.0-test8 #12 Sun Oct 19 04:44:52 CEST 2003 i686
Locale: LANG=fr_FR@euro, LC_CTYPE=fr_FR@euro

Versions of packages gcc-3.2 depends on:
ii  binutils                   2.14.90.0.6-3 The GNU assembler, linker and bina
ii  cpp-3.2                    1:3.2.3-8     The GNU C preprocessor
ii  gcc-3.2-base               1:3.2.3-8     The GNU Compiler Collection (base 
ii  libc6                      2.3.2-8       GNU C Library: Shared libraries an
ii  libgcc1                    1:3.3.2-0pre5 GCC support library

-- no debconf information

#include <stdio.h>

// d is calculated through my use of he c temp double to fix the rounding error
// dold does exactly what the code in gecko does
// note that d/dold are tested in gecko as the breaking condition after being multiplied by ten.
// i set L as long (on my platform it s equal to uint32 whiwh is the Long type used by mozilla

int main(){
  // those values are those i got from my instance of mozilla
  double d=5000340000.;
  double dold=5000340000.;
  double ds=1000000000.;
  long L;
  double c;
  int testlimit = 6;
  int i = 1;
  
  for(i=1;i<testlimit;i++){
    L = (long) (d/ds);
    c= L*ds;
    d -= c;
    d*=10;
    printf("d n°%d: %f\n",i,d);
  }
  
  for(i=1;i<testlimit;i++){
    L = (long) (dold/ds);
    dold -= L*ds;
    dold*=10;
    printf("dold n°%d: %f\n",i,dold);
  } 
  
  printf("%f %f %f \n",d, dold, c);
  return 0;
}

Reply to: