Article View: gnu.gcc.bug
Article #2224bug in sparc gcc 1.32
From: Tom Quinn
Date: Thu, 02 Feb 1989 15:30
Date: Thu, 02 Feb 1989 15:30
114 lines
4144 bytes
4144 bytes
The following code is compiled incorrectly by gcc with the "-g -O"
options. This is gcc version 1.32 on a Sun 4/110 running SunOs 4.0.
The problem is that at line 62 it uses a global symbol (_shrinkFactor)
as the destination of a "st" instruction. However, st can only take
an immediate of 13 bits. The global symbol is generally greater than
13 bits, gets truncated, and running the code causes a segmentation
fault.
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
The compile:
gcc -g -v -S -O -sun4 -c texx.c
gcc version 1.32
/usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ texx.c /tmp/cca27101.cpp
GNU CPP version 1.32
/usr/local/lib/gcc-cc1 /tmp/cca27101.cpp -quiet -dumpbase texx.c -g -O -version -o texx.s
GNU C version 1.32 (sparc) compiled by GNU C version 1.32.
The offending assembly:
.stabn 68,0,62,LM21
LM21:
tst %o0
bne L5
nop
b L6
mov 0,%o0
L5:
call _atoi,0
nop
L6:
st %o0,[_shrinkFactor] ! Segmentation fault here
The code:
------------------------------------------------------------------------
typedef struct _XDisplay {
int fd;
} Display;
Display *XOpenDisplay();
char *XGetDefault();
char *XDisplayName();
unsigned long XBlackPixel();
extern struct _iobuf {
int _cnt;
unsigned char *_ptr;
unsigned char *_base;
int _bufsiz;
short _flag;
char _file;
} _iob[];
extern int dviHHMargin;
extern int dviVVMargin;
extern int dviDPI;
extern int dviBlackness;
extern char *ProgName;
extern int dviInit();
Display *DISP;
static int Leaves;
int shrinkFactor[2 ];
static int reverse = 0;
char *malloc(), *calloc(), *index();
int Black_Pixel = 0;
main(argc, argv)
int argc;
char **argv;
{
char *display = 0 ;
char *option;
int bwidth = 2;
char *fore_color;
char *back_color;
char *high_color;
char *brdr_color;
char *mous_color;
double atof();
char *getenv();
ProgName = *argv;
argv++;
argc--;
if ((DISP = XOpenDisplay(display)) == 0 ) {
fprintf((&_iob[2]) , "[%s] Can't open display '%s'\n",
ProgName, XDisplayName(display));
exit(1);
}
Black_Pixel = XBlackPixel(DISP, 0);
if ((option = XGetDefault(DISP, ProgName, "ReverseVideo")) &&
strcmp(option, "on") == 0)
reverse = 1;
if (option = XGetDefault(DISP, ProgName, "BorderWidth"))
bwidth = atoi(option);
fore_color = XGetDefault(DISP, ProgName, "ForeGround");
back_color = XGetDefault(DISP, ProgName, "BackGround");
high_color = XGetDefault(DISP, ProgName, "Highlight");
brdr_color = XGetDefault(DISP, ProgName, "Border");
mous_color = XGetDefault(DISP, ProgName, "Mouse");
option = XGetDefault(DISP, ProgName, "NormalShrink");
shrinkFactor[0 ] = (option == 0) ? 0 : atoi(option);
option = XGetDefault(DISP, ProgName, "LargeShrink");
shrinkFactor[1 ] = (option == 0) ? 0 : atoi(option);
option = XGetDefault(DISP, ProgName, "Blackness");
dviBlackness = (option == 0) ? 3 : atoi(option);
option = XGetDefault(DISP, ProgName, "Leaves");
Leaves = (option == 0) ? 0 : atoi(option);
option = XGetDefault(DISP, ProgName, "Dpi");
dviDPI = (option == 0) ? 300 : atoi(option);
option = XGetDefault(DISP, ProgName, "TopMargin");
dviVVMargin = (option == 0) ? 300 : atof(option) * dviDPI;
option = XGetDefault(DISP, ProgName, "SideMargin");
dviHHMargin = (option == 0) ? 300 : atof(option) * dviDPI;
dviInit();
}
Technical Details
Message-ID:
<8902021530.AA02268@moose.cita.utoronto.ca>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!xanth!nic.MR.NET!csd4.milw.wisc.edu!bbn!mailrus!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trqShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!xanth!nic.MR.NET!csd4.milw.wisc.edu!bbn!mailrus!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.32 Message-ID: <8902021530.AA02268@moose.cita.utoronto.ca> Date: 2 Feb 89 15:30:30 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 114