Article View: gnu.gcc.bug
Article #1600gcc-2.3.3 - bug on SUN for (char *) within a struct
From: Lack Mr G M
Date: Thu, 07 Jan 1993 14:47
Date: Thu, 07 Jan 1993 14:47
120 lines
3142 bytes
3142 bytes
I wish to report a bug in gcc-2.3.3 on a SUN.
I have built gcc-2.3.3 on a Sun Sparcstation at SunOS4.1.1. The
configure option was "sparc-sun-sunos4.1" and I used CFLAGS=-O during
the makeing, which completed with no errors.
The following simple program dies with a segmentation fault. It
runs correctly with gcc-2.3.3 on an SG Indigo, with Suns own cc compiler
(and with other c compilers on other platforms).
It appears that the address of the "string-within-a-structure" is
not calculated correctly. I append the source and the assembler listing
produced by gcc -S.
==================== Begin test source ====================
#include <stdio.h>
#include <string.h>
struct button {
char *str ;
int opdisp ;
} ;
struct button buttons[2] = {
{ "ab00", 0, },
{ "ab01", 1, },
};
void main()
{
printf("Strings are %s and %s\n", buttons[0].str, buttons[1].str);
strcpy(buttons[0].str, "zz00");
strcpy(buttons[1].str, "zz01");
printf("Strings become %s and %s\n", buttons[0].str, buttons[1].str);
return;
}
==================== End test source ====================
==================== Begin assembler listing ====================
gcc2_compiled.:
.global _buttons
.text
.align 8
LC0:
.ascii "ab00\0"
.align 8
LC1:
.ascii "ab01\0"
.data
.align 4
_buttons:
.word LC0
.word 0
.word LC1
.word 1
.text
.align 8
LC2:
.ascii "Strings are %s and %s\12\0"
.align 8
LC3:
.ascii "zz00\0"
.align 8
LC4:
.ascii "zz01\0"
.align 8
LC5:
.ascii "Strings become %s and %s\12\0"
.align 4
.global _main
.proc 020
_main:
!#PROLOGUE# 0
save %sp,-136,%sp
!#PROLOGUE# 1
call ___main,0
nop
sethi %hi(_buttons),%o1
sethi %hi(_buttons+8),%o2
sethi %hi(LC2),%o3
or %o3,%lo(LC2),%o0
ld [%o1+%lo(_buttons)],%o1
ld [%o2+%lo(_buttons+8)],%o2
call _printf,0
nop
sethi %hi(_buttons),%o1
ld [%o1+%lo(_buttons)],%o0
sethi %hi(LC3),%o2
or %o2,%lo(LC3),%o1
call _strcpy,0
nop
sethi %hi(_buttons+8),%o1
ld [%o1+%lo(_buttons+8)],%o0
sethi %hi(LC4),%o2
or %o2,%lo(LC4),%o1
call _strcpy,0
nop
sethi %hi(_buttons),%o1
sethi %hi(_buttons+8),%o2
sethi %hi(LC5),%o3
or %o3,%lo(LC5),%o0
ld [%o1+%lo(_buttons)],%o1
ld [%o2+%lo(_buttons+8)],%o2
call _printf,0
nop
b L1
nop
L1:
ret
restore
==================== End assembler listing ====================
-------------------------- Gordon Lack ----------------------------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
Technical Details
Message-ID:
<9301071447.AA12676@uk0x06.ggr.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ggr.co.UK!gml4410Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ggr.co.UK!gml4410 From: gml4410@ggr.co.UK (Lack Mr G M) Subject: gcc-2.3.3 - bug on SUN for (char *) within a struct Message-ID: <9301071447.AA12676@uk0x06.ggr.co.uk> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 7 Jan 1993 14:47:43 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 121