Article View: gnu.g++.bug
Article #228More constructor problems
From: Tor Egge
Date: Fri, 10 Apr 1992 18:47
Date: Fri, 10 Apr 1992 18:47
255 lines
4965 bytes
4965 bytes
Compiler: gcc 2.1 (m88k-dolphin-svr3)
When preparing the argument area for a function call, the same argument area is
used (and trashed) when calling a constructor, and the program dumps core (bus
error) .
Compiler: gcc 2.0 (decstation)
Probably the same thing here. (Process killed on unaligned bus access).
- Tor Egge
---- teststruc.cc
#include <stdio.h>
class a
{
int b,c,d;
public:
a(int b1,int c1,int d1);
a(a& in);
void print(char *pr);
};
a::a(a& in) { b=in.b; c=in.c; d=in.d;}
a::a(int b1,int c1,int d1) { b=b1; c=c1; d=d1; }
void a::print(char *pr) { printf("%s:{%d,%d,%d}\n",pr,b,c,d); }
void grumble(a first,a second)
{ first.print("first"); second.print("second"); }
int main()
{ grumble(a(1,2,3),a(1,4,3)); }
----- Makefile
CC=gcc
all: teststruc
head -10 teststruc.s
echo running
teststruc
teststruc: teststruc.o
$(CC) -o teststruc teststruc.o
teststruc.o: teststruc.s
as teststruc.s -o teststruc.o
teststruc.s: teststruc.cc Makefile
$(CC) -S -fomit-frame-pointer teststruc.cc
------- teststruc.s
file "teststruc.cc"
data
; cc1 (2.1) arguments: -fdefer-pop -fomit-frame-pointer -fpeephole
; -ffunction-cse -fcommon -fgnu-linker -Wreturn-type -m88100 -mocs-debug-info
; -mocs-frame-position -mcheck-zero-division
gcc2_compiled.:
text
align 16
global ___1aRT0
___1aRT0:
@Ltb0:
or r13,r0,r2 ; first time, r2=r31, second time r2=r31+12
st r3,r31,4
ld r12,r31,4
ld r11,r0,r12
st r11,r0,r13
ld r12,r31,4
ld r11,r12,4
st r11,r13,4 ; stomps saved version of r3
ld r12,r31,4 ; now illegal value (should be equal to r3)
ld r11,r12,8 ; and crash.
st r11,r13,8
@L2:
or r2,r0,r13
br @L1
align 8
br @L1
align 8
@L1:
@Lte0:
jmp r1
section .tdesc,"x"
word 66,1,@Ltb0,@Lte0,0x100001f,0x0,0x1,0x8
text
align 16
global ___1aiii
___1aiii:
@Ltb1:
or r13,r0,r2
st r3,r31,4
st r4,r31,8
st r5,r31,12
ld r12,r31,4
st r12,r0,r13
ld r12,r31,8
st r12,r13,4
ld r12,r31,12
st r12,r13,8
@L4:
or r2,r0,r13
br @L3
align 8
br @L3
align 8
@L3:
@Lte1:
jmp r1
section .tdesc,"x"
word 66,1,@Ltb1,@Lte1,0x100001f,0x0,0x1,0x8
text
align 4
@LC0:
string "%s:{%d,%d,%d}\012\000"
align 16
global _print__1aPc
_print__1aPc:
subu r31,r31,48
st r1,r31,36
st r25,r31,32
@Ltb2:
or r25,r0,r2
st r3,r31,52
or.u r13,r0,hi16(@LC0)
or r2,r13,lo16(@LC0)
ld r3,r31,52
ld r4,r0,r25
ld r5,r25,4
ld r6,r25,8
bsr _printf
@L5:
@Lte2:
ld r1,r31,36
ld r25,r31,32
addu r31,r31,48
jmp r1
section .tdesc,"x"
word 66,1,@Ltb2,@Lte2,0x100103f,0x30,0xfffffff4,0xfffffff0
text
align 4
@LC1:
string "first\000"
align 4
@LC2:
string "second\000"
align 16
global _grumble__FG1aT0
_grumble__FG1aT0:
subu r31,r31,48
st r1,r31,36
@Ltb3:
addu r12,r31,48
or r2,r0,r12
or.u r13,r0,hi16(@LC1)
or r3,r13,lo16(@LC1)
bsr _print__1aPc
addu r13,r31,60
or r2,r0,r13
or.u r13,r0,hi16(@LC2)
or r3,r13,lo16(@LC2)
bsr _print__1aPc
@L6:
@Lte3:
ld r1,r31,36
addu r31,r31,48
jmp r1
section .tdesc,"x"
word 66,1,@Ltb3,@Lte3,0x100003f,0x30,0xfffffff4,0xfffffff4
text
align 16
global _main
_main:
subu r31,r31,128
st r1,r31,68
st r25,r31,64
@Ltb4:
bsr ___main
addu r2,r31,72
or r3,r0,1
or r4,r0,2
or r5,r0,3
bsr ___1aiii
or r13,r0,r2
or r2,r0,r31 ; NB!
addu r3,r31,72
bsr ___1aRT0
or r13,r0,r2
addu r25,r31,12 ; NB!
addu r13,r31,88
addu r12,r31,104
or r10,r0,r31
ld r11,r10,0
ld r9,r10,4
st r11,r12,0
ld r11,r10,8
st r9,r12,4
st r11,r12,8
or r2,r0,r13
or r3,r0,1
or r4,r0,4
or r5,r0,3
bsr ___1aiii
or r12,r0,r2
or r13,r0,r31
addu r11,r31,104
ld r12,r11,0
ld r10,r11,4
st r12,r13,0
ld r12,r11,8
st r10,r13,4
st r12,r13,8
addu r13,r31,88
addu r12,r31,104
or r10,r0,r31
ld r11,r10,0
ld r9,r10,4
st r11,r12,0
ld r11,r10,8
st r9,r12,4
st r11,r12,8
or r2,r0,r25 ; NB!
or r3,r0,r13
bsr ___1aRT0
or r12,r0,r2
or r13,r0,r31
addu r11,r31,104
ld r12,r11,0
ld r10,r11,4
st r12,r13,0
ld r12,r11,8
st r10,r13,4
st r12,r13,8
bsr _grumble__FG1aT0
or r2,r0,0
br @L7
align 8
br @L7
align 8
@L7:
@Lte4:
ld r1,r31,68
ld r25,r31,64
addu r31,r31,128
jmp r1
section .tdesc,"x"
word 66,1,@Ltb4,@Lte4,0x100103f,0x80,0xffffffc4,0xffffffc0
text
----- The End
Technical Details
Message-ID:
<1992Apr10.184756.5143@ugle.unit.no>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!flipper.pvv.unit.no!teggeShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!flipper.pvv.unit.no!tegge From: tegge@flipper.pvv.unit.no (Tor Egge) Subject: More constructor problems Message-ID: <1992Apr10.184756.5143@ugle.unit.no> Sender: gnulists@ai.mit.edu Organization: ProgramVareVerkstedet - UNIT Distribution: gnu Date: Fri, 10 Apr 1992 18:47:56 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 256