From: karl@claude.cs.umb.edu (Karl Berry)
Newsgroups: gnu.gcc.bug
Subject: GCC 2.3.1 on IBM RT -- bad assembly code
Date: 11 Nov 92 05:58:37 GMT
Article-I.D.: claude.199211111558.AA01987
Reply-To: karl@cs.umb.edu
Distribution: gnu
Organization: Gnus Not Usenet

gcc 2.3.1 on an IBM RT running AOS (4.3 BSD), configured as romp-aos,
generates bad assembly code for the following program.  (This bug was
also present in 2.2.2.)  I invoke gcc as:

gcc -g -v -c strtod.i

and get the following output:

Reading specs from /usr/local/gnu/lib/gcc-lib/romp-aos/2.3.1/specs
gcc version 2.3.1
 /usr/local/gnu/lib/gcc-lib/romp-aos/2.3.1/cc1 strtod.i -quiet -version -o /tmp/cc006906.s
GNU C version 2.3.1 compiled by GNU C version 2.3.1.
 as -o strtod.o /tmp/cc006906.s
Assembler:
"/tmp/cc006909.s", line 256: Badly formatted floating point number.
"/tmp/cc006909.s", line 256: Badly formatted floating point number.
"/tmp/cc006909.s", line 441: "INF" is not followed by a ':' for a label definition
"/tmp/cc006909.s", line 547: "INF" is not followed by a ':' for a label definition
gcc: strtod.o: No such file or directory

Following is the preprocessed input file strtod.i, a ^L, and the
assembly output.

# 1 "strtod.c"
 

















# 1 "/usr/include/errno.h" 1 3
 




 
 
 






# 1 "/usr/include/sys/nfs_defines.h" 1 3
 




 
 
 





 



 





















# 15 "/usr/include/errno.h" 2 3



 







 




































 



 






 

	 













	 













	 



 




 

















 



 




# 19 "strtod.c" 2

# 1 "/usr/include/ctype.h" 1 3
 



 
 
 





 










extern	char	_ctype_[];
















# 20 "strtod.c" 2

# 1 "/usr/include/math.h" 1 3
 



 
 
 





 

extern double asinh(), acosh(), atanh();
extern double erf(), erfc();
extern double fabs(), floor(), ceil(); 
extern double modf(), ldexp(), frexp(), atof();
extern double sqrt(), cbrt();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double expm1(), log1p(), exp(), log(), log10(), pow();
extern double sinh(), cosh(), tanh();
extern double hypot(), cabs(), lgamma();
extern double j0(), j1(), jn(), y0(), y1(), yn();






# 21 "strtod.c" 2










extern int errno;









 

double
strtod (nptr, endptr)
     const char *nptr;
     char **endptr;
{
  register const char *s;
  short int sign;

   
  double num;

  int got_dot;			 
  int got_digit;		 

   
  long int exponent;

  if (nptr == 0 )
    {
      errno = 	22		;
      goto noconv;
    }

  s = nptr;

   
  while (((_ctype_+1)[*s]&010 ) )
    ++s;

   
  sign = *s == '-' ? -1 : 1;
  if (*s == '-' || *s == '+')
    ++s;

  num = 0.0;
  got_dot = 0;
  got_digit = 0;
  exponent = 0;
  for (;; ++s)
    {
      if (((_ctype_+1)[*s]&04 ) )
	{
	  got_digit = 1;

	   
	  if (num > 1.7976931348623159e+308  * 0.1)
	     






	    ++exponent;
	  else
	    num = (num * 10.0) + (*s - '0');

	   

	  if (got_dot)
	    --exponent;
	}
      else if (!got_dot && *s == '.')
	 
	got_dot = 1;
      else
	 
	break;
    }

  if (!got_digit)
    goto noconv;

  if (((*s)-'A'+'a')  == 'e')
    {
       
      int save = errno;
      char *end;
      long int exp;

      errno = 0;
      ++s;
      exp = strtol (s, &end, 10);
      if (errno == 	34		)
	{
	   


	  if (endptr != 0 )
	    *endptr = end;
	  if (exp < 0)
	    goto underflow;
	  else
	    goto overflow;
	}
      else if (end == s)
	 

	end = (char *) s - 1;
      errno = save;
      s = end;
      exponent += exp;
    }

  if (endptr != 0 )
    *endptr = (char *) s;

  if (num == 0.0)
    return 0.0;

   


  if (exponent < 0)
    {
      if (num < 2.2250738585072010e-308  * pow (10.0, (double) -exponent))
	goto underflow;
    }
  else if (exponent > 0)
    {
      if (num > 1.7976931348623159e+308  * pow (10.0, (double) -exponent))
	goto overflow;
    }

  num *= pow (10.0, (double) exponent);

  return num * sign;

overflow:
   
  errno = 	34		;
  return 1.7976931348623158e308   * sign;

underflow:
   
  if (endptr != 0 )
    *endptr = (char *) nptr;
  errno = 	34		;
  return 0.0;

noconv:
   
  if (endptr != 0 )
    *endptr = (char *) nptr;
  return 0.0;
}

	.globl .oVncs
	.set .oVncs,0
	.globl .oVgcc2.3.1
	.set .oVgcc2.3.1,0
gcc2_compiled.:
.stabs "/usr/local/src/gnu/shellutils-1.8/lib/",100,0,0,Ltext0
.stabs "strtod.c",100,0,0,Ltext0
.text
Ltext0:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r1;0;255;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.data
	.align 2
_strtod:
	.long _.strtod, 0, 0
	.align 2
LC0:
	.double 0d0.00000000000000000000e+00
	.align 2
LC1:
	.long _strtol
	.align 2
LC2:
	.double 0d1.00000000000000000000e+01
	.align 2
LC3:
	.long _pow
.text
	.align 1
	.globl _strtod
	.globl _.strtod
_.strtod:
	.stabd 68,0,47
	stm r11,-56(r1)
	cas r14,r0,r0
	cal r13,-192(r1)
	cal r1,-164(r1)
	cal r15,36(r14)
	balr r15,r15
	st r2,176(r13)
	st r3,180(r13)
	.stabd 68,0,48
LBB2:
	.stabd 68,0,60
	l r0,176(r13)
	cis r0,0
	bne L2
	.stabd 68,0,62
	cal r0,22(r0)
	store r0,_errno,r11
	.stabd 68,0,63
	b L3
L2:
	.stabd 68,0,66
	l r12,176(r13)
	.stabd 68,0,69
L4:
	lcs r0,0(r12)
	nilz r4,r0,255
	loadc r3,__ctype_+1(r4)
	nilz r0,r3,8
	nilz r4,r0,255
	cis r4,0
	beq L5
	.stabd 68,0,70
	ais r12,1
	b L4
L5:
	.stabd 68,0,73
	lcs r4,0(r12)
	nilz r0,r4,255
	cil r0,45
	bne L6
	cal r0,65535(r0)
	b L7
L6:
	lis r0,1
L7:
	sth r0,62(r13)
	.stabd 68,0,74
	lcs r4,0(r12)
	nilz r0,r4,255
	cil r0,45
	beq L9
	lcs r4,0(r12)
	nilz r0,r4,255
	cil r0,43
	beq L9
	b L8
L9:
	.stabd 68,0,75
	ais r12,1
L8:
	.stabd 68,0,77
	l r0,16(r14)
	sts r0,56(r13)
	ls r0,12(r14)
	sts r0,52(r13)
	.stabd 68,0,78
	lis r0,0
	sts r0,48(r13)
	.stabd 68,0,79
	lis r0,0
	sts r0,44(r13)
	.stabd 68,0,80
	lis r0,0
	sts r0,40(r13)
L10:
	.stabd 68,0,83
	lcs r0,0(r12)
	nilz r4,r0,255
	loadc r3,__ctype_+1(r4)
	nilz r0,r3,4
	nilz r4,r0,255
	cis r4,0
	beq L13
	.stabd 68,0,85
	lis r0,1
	sts r0,44(r13)
	.stabd 68,0,88
	cal r15,88(r14)
	balr r15,r15
	ble L14
	.stabd 68,0,96
	ls r0,40(r13)
	ail r4,r0,1
	sts r4,40(r13)
	b L15
L14:
	.stabd 68,0,98
	cal r15,320(r14)
	balr r15,r15
	lcs r0,0(r12)
	nilz r4,r0,255
	ail r3,r4,-48
	cal r15,424(r14)
	balr r15,r15
	cal r15,508(r14)
	balr r15,r15
L15:
	.stabd 68,0,102
	ls r0,48(r13)
	cis r0,0
	beq L16
	.stabd 68,0,103
	ls r0,40(r13)
	ail r4,r0,-1
	sts r4,40(r13)
L16:
	.stabd 68,0,104
	b L17
L13:
	.stabd 68,0,105
	ls r0,48(r13)
	cis r0,0
	bne L18
	lcs r4,0(r12)
	nilz r0,r4,255
	cil r0,46
	bne L18
	.stabd 68,0,107
	lis r0,1
	sts r0,48(r13)
	b L19
L18:
	.stabd 68,0,110
	b L11
L19:
L17:
	.stabd 68,0,81
L12:
	ais r12,1
	b L10
L11:
	.stabd 68,0,113
	ls r0,44(r13)
	cis r0,0
	bne L20
	.stabd 68,0,114
	b L3
L20:
	.stabd 68,0,116
	lcs r4,0(r12)
	nilz r0,r4,255
	ail r4,r0,32
	cil r4,101
	bne L21
	.stabd 68,0,119
LBB3:
	load r4,_errno
	sts r4,36(r13)
	.stabd 68,0,123
	lis r0,0
	store r0,_errno,r11
	.stabd 68,0,124
	ais r12,1
	.stabd 68,0,125
	ail r0,r13,32
	cas r2,r12,r0
	cas r3,r0,r0
	lis r4,10
	ls r5,20(r14)
	cas r0,r5,r0
	bali r15,_.strtol
	sts r2,28(r13)
	.stabd 68,0,126
	load r4,_errno
	cil r4,34
	bne L22
	.stabd 68,0,131
	l r0,180(r13)
	cis r0,0
	beq L23
	.stabd 68,0,132
	l r4,180(r13)
	ls r0,32(r13)
	sts r0,0(r4)
L23:
	.stabd 68,0,133
	ls r0,28(r13)
	cis r0,0
	bhe L24
	.stabd 68,0,134
	b L25
	b L26
L24:
	.stabd 68,0,136
	b L27
L26:
	.stabd 68,0,137
	b L28
L22:
	.stabd 68,0,138
	ls r0,32(r13)
	c r0,r12
	bne L29
	.stabd 68,0,141
	ail r0,r12,-1
	sts r0,32(r13)
L29:
L28:
	.stabd 68,0,142
	ls r0,36(r13)
	store r0,_errno,r11
	.stabd 68,0,143
	ls r12,32(r13)
	.stabd 68,0,144
	ls r0,40(r13)
	ls r4,28(r13)
	a r0,r4
	sts r0,40(r13)
	.stabd 68,0,145
LBE3:
L21:
	.stabd 68,0,147
	l r0,180(r13)
	cis r0,0
	beq L30
	.stabd 68,0,148
	l r4,180(r13)
	sts r12,0(r4)
L30:
	.stabd 68,0,150
	cal r15,580(r14)
	balr r15,r15
	bne L31
	.stabd 68,0,151
	l r3,16(r14)
	ls r2,12(r14)
	b L1
L31:
	.stabd 68,0,156
	ls r0,40(r13)
	cis r0,0
	bhe L32
	.stabd 68,0,158
	ls r4,40(r13)
	twoc r3,r4
	cal r15,780(r14)
	balr r15,r15
	l r3,28(r14)
	ls r2,24(r14)
	cas r4,r4,r0
	cas r5,r5,r0
	ls r15,32(r14)
	cas r0,r15,r0
	bali r15,_.pow
	cal r15,960(r14)
	balr r15,r15
	cal r15,1032(r14)
	balr r15,r15
	cal r15,1104(r14)
	balr r15,r15
	bhe L33
	.stabd 68,0,159
	b L25
L33:
	.stabd 68,0,160
	b L34
L32:
	.stabd 68,0,161
	ls r0,40(r13)
	cis r0,0
	ble L35
	.stabd 68,0,163
	ls r4,40(r13)
	twoc r3,r4
	cal r15,780(r14)
	balr r15,r15
	l r3,28(r14)
	ls r2,24(r14)
	cas r4,r4,r0
	cas r5,r5,r0
	ls r15,32(r14)
	cas r0,r15,r0
	bali r15,_.pow
	cal r15,960(r14)
	balr r15,r15
	cal r15,1304(r14)
	balr r15,r15
	cal r15,1104(r14)
	balr r15,r15
	ble L36
	.stabd 68,0,164
	b L27
L36:
L35:
L34:
	.stabd 68,0,167
	cal r15,1376(r14)
	balr r15,r15
	l r3,28(r14)
	ls r2,24(r14)
	cas r4,r4,r0
	cas r5,r5,r0
	ls r15,32(r14)
	cas r0,r15,r0
	bali r15,_.pow
	cal r15,960(r14)
	balr r15,r15
	cal r15,1556(r14)
	balr r15,r15
	.stabd 68,0,169
	lh r3,62(r13)
	exts r4,r3
	cal r15,1628(r14)
	balr r15,r15
	cal r15,1712(r14)
	balr r15,r15
	b L1
L27:
	.stabd 68,0,173
	cal r0,34(r0)
	store r0,_errno,r11
	.stabd 68,0,174
	lh r3,62(r13)
	exts r4,r3
	cal r15,1628(r14)
	balr r15,r15
	cal r15,1880(r14)
	balr r15,r15
	b L1
L25:
	.stabd 68,0,178
	l r0,180(r13)
	cis r0,0
	beq L37
	.stabd 68,0,179
	l r4,180(r13)
	l r0,176(r13)
	sts r0,0(r4)
L37:
	.stabd 68,0,180
	cal r0,34(r0)
	store r0,_errno,r11
	.stabd 68,0,181
	l r3,16(r14)
	ls r2,12(r14)
	b L1
L3:
	.stabd 68,0,185
	l r0,180(r13)
	cis r0,0
	beq L38
	.stabd 68,0,186
	l r4,180(r13)
	l r0,176(r13)
	sts r0,0(r4)
L38:
	.stabd 68,0,187
	l r3,16(r14)
	ls r2,12(r14)
	b L1
	.stabd 68,0,188
LBE2:
	.stabd 68,0,188
L1:
	cal r15,2048(r14)
	balr r15,r15
	lm r11,108(r1)
	brx r15
	cal r1,164(r1)
	.long 0xdf07dfb8
	.byte 0x2d, 53
.data
	.align 2
# data area offset = 36
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x1d	# STOREM
	.byte 2
	.short 0x8001
	.byte 52, 0x80
	.byte 0xff,0x20 # (int) $
	.byte 0x30,0x1 # (int) 36(r1)
	.long 36
	.space 32
# data area offset = 88
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x08	# CMPT
	.byte 2
	.short 0x8001
	.byte 232, 0x80
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x23,0x0 # (double) $
	.long 52
	.double 0dINF
	.space 204
# data area offset = 320
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 3
	.short 0x8001
	.byte 104, 0x80
	.byte 0x13,0x1 # (double) fr1
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x23,0x0 # (double) $
	.space 2
	.long 52
	.double 0d1.00000000000000000000e+01
	.space 72
# data area offset = 424
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x14	# MOVE
	.byte 2
	.short 0x8001
	.byte 84, 0x80
	.byte 0x13,0x2 # (double) fr2
	.byte 0x0,0x3 # (int) r3
	.space 68
# data area offset = 508
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x02	# ADD
	.byte 3
	.short 0x8001
	.byte 72, 0x80
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x13,0x1 # (double) fr1
	.byte 0x13,0x2 # (double) fr2
	.space 2
	.long 52
	.space 48
# data area offset = 580
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x07	# CMP
	.byte 2
	.short 0x8001
	.byte 200, 0x80
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x23,0x0 # (double) $
	.long 52
	.double 0d0.00000000000000000000e+00
	.space 172
# data area offset = 780
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x14	# MOVE
	.byte 2
	.short 0x8001
	.byte 180, 0x80
	.byte 0x3,0x45 # (double) r4
	.byte 0x0,0x3 # (int) r3
	.space 164
# data area offset = 960
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x14	# MOVE
	.byte 2
	.short 0x8001
	.byte 72, 0x80
	.byte 0x13,0x1 # (double) fr1
	.byte 0x3,0x23 # (double) r2
	.space 56
# data area offset = 1032
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 3
	.short 0x8001
	.byte 72, 0x80
	.byte 0x13,0x2 # (double) fr2
	.byte 0x13,0x1 # (double) fr1
	.byte 0x23,0x0 # (double) $
	.space 2
	.double 0d2.22507385850720100000e-308
	.space 44
# data area offset = 1104
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x08	# CMPT
	.byte 2
	.short 0x8001
	.byte 200, 0x80
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x13,0x2 # (double) fr2
	.long 52
	.space 180
# data area offset = 1304
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 3
	.short 0x8001
	.byte 72, 0x80
	.byte 0x13,0x2 # (double) fr2
	.byte 0x13,0x1 # (double) fr1
	.byte 0x23,0x0 # (double) $
	.space 2
	.double 0dINF
	.space 44
# data area offset = 1376
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x14	# MOVE
	.byte 2
	.short 0x8001
	.byte 180, 0x80
	.byte 0x3,0x45 # (double) r4
	.byte 0x30,0xd # (int) 40(r13)
	.long 40
	.space 160
# data area offset = 1556
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 2
	.short 0x8001
	.byte 72, 0x80
	.byte 0x33,0xd # (double) 52(r13)
	.byte 0x13,0x1 # (double) fr1
	.long 52
	.space 52
# data area offset = 1628
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x14	# MOVE
	.byte 2
	.short 0x8001
	.byte 84, 0x80
	.byte 0x13,0x1 # (double) fr1
	.byte 0x0,0x4 # (int) r4
	.space 68
# data area offset = 1712
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 3
	.short 0x8001
	.byte 168, 0x80
	.byte 0x3,0x23 # (double) r2
	.byte 0x13,0x1 # (double) fr1
	.byte 0x33,0xd # (double) 52(r13)
	.space 2
	.long 52
	.space 144
# data area offset = 1880
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x15	# MUL
	.byte 3
	.short 0x8001
	.byte 168, 0x80
	.byte 0x3,0x23 # (double) r2
	.byte 0x13,0x1 # (double) fr1
	.byte 0x23,0x0 # (double) $
	.space 2
	.double 0d1.79769313486231580000e+308
	.space 140
# data area offset = 2048
	cas r0,r15,r0
	.long FPGLUE
	.byte 0x0f	# LOADM
	.byte 2
	.short 0x8001
	.byte 52, 0x80
	.byte 0xff,0x20 # (int) $
	.byte 0x30,0x1 # (int) 36(r1)
	.long 36
	.space 32
.text
.stabs "strtod:F13",36,0,0,_strtod
.stabs "nptr:p16=*2",160,0,0,176
.stabs "endptr:p17=*18=*2",160,0,0,180
.stabs "s:r16",64,0,0,12
.stabs "sign:6",128,0,0,62
.stabs "num:13",128,0,0,52
.stabs "got_dot:1",128,0,0,48
.stabs "got_digit:1",128,0,0,44
.stabs "exponent:3",128,0,0,40
.stabn 192,0,0,LBB2
.stabs "save:1",128,0,0,36
.stabs "end:18",128,0,0,32
.stabs "exp:3",128,0,0,28
.stabn 192,0,0,LBB3
.stabn 224,0,0,LBE3
.stabn 224,0,0,LBE2