🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2256

bug in sparc gcc 1.33

#2256
From: Tom Quinn
Date: Wed, 08 Feb 1989 19:45
93 lines
2792 bytes
The following code will compile incorrectly with the "-O" and
"-fforce-addr" flags.  This is on a Sun4/110 running SunOs 4.0.
The resulting object will generate a Bus Error at line 27 because it
is doing a "std" (store double) with an address that is not aligned on
an 8 byte boundary.

The compile:
gcc -S -g -v -O -fforce-addr -c axis.c -o axis.o
gcc version 1.33
 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ axis.c /tmp/cca19292.cpp
GNU CPP version 1.33
 /usr/local/lib/gcc-cc1 /tmp/cca19292.cpp -quiet -dumpbase axis.c -fforce-addr -g -O -version -o axis.o
GNU C version 1.33 (sparc) compiled by GNU C version 1.33.

The bad assembly:
L6:
.stabn 68,0,27,LM12
LM12:
	st %l1,[%fp-4]
	ld [%fp-4],%f8
	fstod %f8,%f6
	std %f6,[%fp-8]
	ldd [%fp-8],%l6
	fstod %f2,%f6
	std %f6,[%fp-8]
	ldd [%fp-8],%l4
	sethi %hi(_xsmall),%l2
	or %lo(_xsmall),%l2,%l2
	ld [%l2],%f2
	sub %sp,32,%sp
	add %sp,92,%o0		#if sp is 8 byte aligned, o0 is not
	sethi %hi(_xbig),%l3
	or %lo(_xbig),%l3,%l3
	ld [%l3],%f4
	fstod %f4,%f4
	std %f4,[%o0]		# this will cause a bus error
	sethi %hi(_gx1),%l0
	or %lo(_gx1),%l0,%l0
	ld [%l0],%i2
	st %i2,[%o0+8]
	sethi %hi(_gy1),%g1
	ld	[%g1+%lo(_gy1)],%i2
	st %i2,[%o0+12]
	sethi %hi(_gx2),%l1
	or %lo(_gx2),%l1,%l1
	ld [%l1],%o1
	ld [%l0],%o2
	sub %o1,%o2,%o1
	st %o1,[%o0+16]
	st %i0,[%o0+20]
	st %g0,[%o0+24]
	mov %l6,%o0
	mov %l7,%o1
	mov %l4,%o2
	mov %l5,%o3
	fstod %f2,%f6
	std %f6,[%fp-8]
	ldd [%fp-8],%o4
	call _axis,0
	nop


The code:
------------------------------------------------------------------------
extern float 
  	     fx1,fx2;      
extern int   gx1,gx2,gy1,gy2;      
extern double pow();
void angle(),
     ltype();
static float xsmall = 0.,
	     xbig   = 0.;
box(labelxl, labelxu)
int labelxl, labelxu;
{
   float a1,a2;
    ltype(0);
    angle(0.);
    if(xsmall < 0) {                        
       if(fabs(fx1) > 37 || fabs(fx2) > 37) {
	  msg("|x-limits| are too large for logarithmic axes\n");
	  a1 = fx1; a2 =fx2;
	  xsmall = 0;
       } else {
	  a1 = pow(10.,fx1);
	  a2 = pow(10.,fx2);
       }
    } else {				 
       a1 = fx1; a2 =fx2;
    }
    (void)axis(a1,a2,xsmall,xbig,gx1,gy1,gx2-gx1,labelxl,0);
    (void)axis(a1,a2,xsmall,xbig,gx1,gy2,gx2-gx1,labelxu,1);
}
Technical Details
Message-ID: <8902081945.AA06927@moose.cita.utoronto.ca>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trq

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trq
From: trq@MOOSE.CITA.UTORONTO.CA (Tom Quinn)
Newsgroups: gnu.gcc.bug
Subject: bug in sparc gcc 1.33
Message-ID: <8902081945.AA06927@moose.cita.utoronto.ca>
Date: 8 Feb 89 19:45:56 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 93