Again -march=i686 -O bug

Gerhard Heinzel ghh@mpq.mpg.de
Wed Dec 2 08:11:00 GMT 1998


Sorry to repeat this, but the bug is STILL present in the just announced 
19981130 snapshot.

The program below is miscompiled and prints "NaN" instead of "0", when
compiled with -march=i686 -O.


--------------- Compiler specs -----------------------

Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/specs
gcc version egcs-2.92.25 19981130 (gcc2 ss-980609 experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/cpp -lang-c -v
-undef -D__GNUC__=2 -D__GNUC_MINOR__=92 -D__ELF__ -Dunix -D__i386__ -Dlinux
-D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -D__OPTIMIZE__ -Acpu(i386) -Amachine(i386) -Di386 -D__i386
-D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro
-D__pentiumpro__ err.c /tmp/ccZssesp.i
GNU CPP version egcs-2.92.25 19981130 (gcc2 ss-980609 experimental) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/../../../../i686-pc-linux-gnulibc1/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/cc1
/tmp/ccZssesp.i -quiet -dumpbase err.c -march=i686 -O -version -o
/tmp/ccIQYx5O.s
GNU C version egcs-2.92.25 19981130 (gcc2 ss-980609 experimental)
(i686-pc-linux-gnulibc1) compiled by GNU C version egcs-2.92.25 19981130
(gcc2 ss-980609 experimental).
 as -V -Qy -o /tmp/ccp1KMqn.o /tmp/ccIQYx5O.s
GNU assembler version 2.8.1 (i486-linux), using BFD version 2.8.1
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/collect2 -m
elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o err /usr/lib/crt1.o
/usr/lib/crti.o
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/crtbegin.o
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25
-L/usr/local/i686-pc-linux-gnulibc1/lib -L/usr/local/lib /tmp/ccp1KMqn.o
-lgcc -lc -lgcc
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.92.25/crtend.o
/usr/lib/crtn.o
 

-------------------- Test program -------------------------------

#include <stdio.h>
#include <math.h>
#define SIZE 10

int
main (void)
{
  int i, j, k;
  double a[SIZE * SIZE], ainv[SIZE * SIZE];
  double diff, sum, soll, maxd;

  /* matrix addressing : a(i,j) = a[n*i+j] */

  /* Normally here 'a' is a double matrix and 'ainv' its inverse */
  /* For testing, set 'a' and 'ainv' as unity matrices */
  for (i = 0; i < SIZE; i++)
    for (j = 0; j < SIZE; j++)
      a[i * SIZE + j] = ainv[i * SIZE + j] = ((i == j) ? 1 : 0);

  /* compute the product a*ainv element by element and compare to
     unity matrix */

  maxd = 0;			/* maximum of difference */
  for (i = 0; i < SIZE; i++)
    for (j = 0; j < SIZE; j++)
      /* compute element (i,j) of product */
      {
/*1*/	sum = 0;
/*2*/	soll = ((i == j) ? 1 : 0);	/* this should be the result */
	for (k = 0; k < SIZE; k++)
	  sum += a[i * SIZE + k] * ainv[k * SIZE + j];
	diff = fabs (sum - soll);	/* measure difference */
	if (diff > maxd)	/* record maximum difference */
	  maxd = diff;
      }
  printf ("maxd=%g \n", maxd);
  return 0;
}


Cheers

Gerhard

=====================================================================
 Gerhard Heinzel                            E-mail:   ghh@mpq.mpg.de
 Max-Planck-Institut fuer Quantenoptik   Phone: +49(89)32905-268/252
 Hans-Kopfermann-Str. 1            Phone (30m Lab): +49(89)3299-3282
 D-85748 Garching                              Fax: +49(89)32905-200  
 Germany                                        http://130.183.90.63
=====================================================================




More information about the Gcc-bugs mailing list