[gnu.gcc.bug] gcc 1.30 dumps core for certain asm constructs.

self@BAYES.ARC.NASA.GOV (Matthew Self) (11/22/88)

======================================================================
gcc 1.30 gets a fatal error compiling certain "asm" constructs....
The following program cause gcc to get fatal error 6:
======================================================================

#include <stdio.h>
#include <math.h>

#define N 100000

#define exp(x)					\
({						\
  double __value,				\
         __x = (x);				\
						\
  asm ("fetox%.x %1,%0"				\
       : "=f" (__value)				\
       : "f" (__x));				\
  __value;					\
})

#define log(x)					\
({						\
  double __value,				\
         __x = (x);				\
						\
  asm ("flogn%.x %1,%0"				\
       : "=f" (__value)				\
       : "f" (__x));				\
  __value;					\
})

main()
{
  int i;
  double x = 2.0;

  for (i = N - 1; i != -1; i--) {
    exp(log(x));
  }
  printf("x = %f\n", x);
}


======================================================================
Here is what is produced by gcc -E:
======================================================================

main()
{
  int i;
  double x = 2.0;
  for (i = 100000  - 1; i != -1; i--) {
    ({
      double __value,
      __x = (({
	double __value,
	__x = (x);
	asm ("flogn%.x %1,%0"
	     : "=f" (__value)
	     : "f" (__x));
	__value;
      }) );
      asm ("fetox%.x %1,%0"
	   : "=f" (__value)
	   : "f" (__x));
      __value;
    }) ;
  }
  printf("x = %f\n", x);
}

======================================================================
Here is the run:
======================================================================

gcc -v -O -g bug.c
gcc version 1.30
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix
 -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 bug.c /tmp/cca10665.cpp
GNU CPP version 1.30
 /usr/local/lib/gcc-cc1 /tmp/cca10665.cpp -quiet -dumpbase bug.c -g -O
 -version -o /tmp/cca10665.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
gcc: Program cc1 got fatal signal 6.

======================================================================
This is on a Sun-3/60 running SunOS 4.0
======================================================================

			Matthew Self
		  NASA Ames Research Center
		   self@bayes.arc.nasa.gov