Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Tom Quinn
Tue, 27 Sep 1988 22:14
structure passing bug in sparc gcc 1.28
Author: Tom Quinn
Date: Tue, 27 Sep 1988 22:14
Date: Tue, 27 Sep 1988 22:14
78 lines
2498 bytes
2498 bytes
The following code demonstrates a bug in gcc v1.28 on sparc when
passing structure values to a function. Two of the parameter passing
registers get smashed while the end of the structure is being put onto
the stack.
This is on a Sun4/110 running SunOS 4.0
The compile:
gcc -g -v -S -sun4 -c control2.c
gcc version 1.28
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dsparc -Dsun -Dunix control2.c /tmp/cca20015.cpp
GNU CPP version 1.28
/usr/local/lib/gcc-cc1 /tmp/cca20015.cpp -quiet -dumpbase control2.c -g -version -o control2.s
GNU C version 1.28 (sparc) compiled by GNU C version 1.28.
The code:
------------------------------------------------------------
typedef struct {
char descrip[80],
*name;
float *vec;
int dimen;
} VECTOR;
typedef union yystype {
char charval[80];
int intval;
};
extern union yystype yylval;
static char data_file[80];
union yystype yylval;
int
yyparse()
{
register union yystype *yyvsp;
union yystype yyvsa[200 ];
union yystype *yyvs = yyvsa;
yyvsp = yyvs;
*++yyvsp = yylval;
{
VECTOR temp;
if(read_row(data_file,yyvsp[0].intval,&temp) == 0) {
copy_vector(yyvsp[-1].charval,temp);
}
;
}
}
--------------------------------------------------------------
The offending assembler:
.stabn 68,0,25,LM6
LM6:
sub %sp,72,%sp
add %l0,-80,%l1
set -16120,%o0
add %fp,%o0,%o0
ld [%o0],%o1 <<<First 4 bytes of structure
ld [%o0+4],%o2 <<<Second 4 bytes of structure
ld [%o0+8],%o3
ld [%o0+12],%o4
ld [%o0+16],%o5
set 68,%o1 <<< OUCH!!
add %sp,76,%o2 <<< OOFF!!
Lm1: <<< Loop to shove the rest onto the stack
ld [%o0+%o1],%g1
subcc %o1,4,%o1
bge Lm1
st %g1,[%o2+%o1]
mov %l1,%o0
call _copy_vector,0
nop
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.toronto.edu
SOON TO BE trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads