[gnu.gcc.bug] i386-sequent,1.35.99 -O generates bad code.

meyering@CS.UTEXAS.EDU (Jim Meyering) (09/18/89)

On the sequent-i386, gcc-1.35.99 has a problem with
the combination of -O, const functions, and ({})-expressions.
I'm not sure if this problem is new with 1.35.99.

With -O and -DBUG, a-b is displayed as 10^292.
Otherwise, the difference is near 0.

% cat main.c
#define ABS(x) ({ __typeof(x) _tmp = (x); \
		(_tmp < 0) ? -(_tmp) : _tmp; })

const double epslon(double x) { return(1.0); }

void
main()
{
	double b,a;
	int i;

	a = 1.1721544271126358;
	b = 1.1721544271126363;
	for (i=0; i<8; i++) {
#define EXPR (ABS(b-a)/epslon(1.0))
		if (EXPR > 1.0) {
			printf("%g %g, diff(units of epslon(1.0)): %g\n",b,a,EXPR);
#ifndef BUG
			printf("\tABS(diff): %g\n", ABS(b-a));
#endif
			exit(2);
			}
		}
	exit(0);
	}
% make
/p/bin/gcc -v -g -O   -c main.c -o main.o
gcc version 1.35.99
/p/bin/gcc -v -g -O -DBUG -c main.c -o main-bug.o
gcc version 1.35.99
 /p/lib/gcc-1.35.99/gcc-cpp -v -undef -D__GNUC__ -Dunix -Di386 -Dsequent -D__unix__ -D__i386__ -D__sequent__ -D__OPTIMIZE__ main.c /usr/tmp/cc000407.cpp
 /p/lib/gcc-1.35.99/gcc-cpp -v -DBUG -undef -D__GNUC__ -Dunix -Di386 -Dsequent -D__unix__ -D__i386__ -D__sequent__ -D__OPTIMIZE__ main.c /usr/tmp/cc000408.cpp
GNU CPP version 1.35.99
GNU CPP version 1.35.99
 /p/lib/gcc-1.35.99/gcc-cc1 /usr/tmp/cc000407.cpp -quiet -dumpbase main.c -g -O -version -o /usr/tmp/cc000407.s
 /p/lib/gcc-1.35.99/gcc-cc1 /usr/tmp/cc000408.cpp -quiet -dumpbase main.c -g -O -version -o /usr/tmp/cc000408.s
GNU C version 1.35.99 (80386, BSD syntax) compiled by GNU C version 1.35.99.
default target switches: -m80387
GNU C version 1.35.99 (80386, BSD syntax) compiled by GNU C version 1.35.99.
default target switches: -m80387
 as -o main-bug.o /usr/tmp/cc000408.s
 as -o main.o /usr/tmp/cc000407.s
/p/bin/gcc -v -g -O -o z-bug main-bug.o -lm
gcc version 1.35.99
/p/bin/gcc -v -g -O -o z main.o -lm
 ld -o z-buggcc version 1.35.99
 /lib/crt0.o main-bug.o -lm /p/lib/gcc-1.35.99/gcc-gnulib -lg -lc
 ld -o z /lib/crt0.o main.o -lm /p/lib/gcc-1.35.99/gcc-gnulib -lg -lc
z
z-bug
1.17215 1.17215, diff(units of epslon(1.0)): 1.14232e+292
make: *** [test] Error 2 (ignored)
2.4u 2.3s 0:05 86% 0+0k 24+45io 2pf+0w
% 

Jim Meyering          meyering@cs.utexas.edu