From: oran@ai.mit.edu (Oran Singer)
Subject: bug for 2.3.3
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sat, 2 Jan 1993 18:14:55 GMT

I am running g++ v.2.3.3 on a sparc with 4.1.2. The following code worked
fine on 2.1, and now the assembler bombs on a redefinition of _try. It was
compiled simply with g++. What follows is the -S output for 2.1 and 2.3.3,
showing the bug in mangling _try correctly, and the output of -g -S for
2.3.3. (If this helps, the problem goes away under certain circumstances if
the function is a friend of some class).

template<class T, class RW_T> T try(T dummy, RW_T dd, int i)
{
	return dummy;	
}

void f()
{
	int i,j;
	char c;
	int k=try(i,c,j);
}

void g()
{
	int i,j;
	char c;
	char k=try(c,i,j);
}

main()
{
	f(); g();
}



for g++ v2.1:

gcc2_compiled.:
.text
	.align 4
	.global _f__Fv
	.proc 1
_f__Fv:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	ld [%fp-20],%o0
	ld [%fp-24],%o2
	call _try__Fici,0
	nop
	st %o0,[%fp-32]
	b,a L2
	b,a L1
L2:
L1:
	ret
	restore
	.align 4
	.global _g__Fv
	.proc 1
_g__Fv:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	mov %o1,%o0
	ld [%fp-20],%o1
	ld [%fp-24],%o2
	call _try__Fcii,0
	nop
	stb %o0,[%fp-26]
	b,a L4
	b,a L3
L4:
L3:
	ret
	restore
	.align 4
	.global _main
	.proc 1
_main:
	!#PROLOGUE# 0
	save %sp,-136,%sp
	!#PROLOGUE# 1
	call ___main,0
	nop
	call _f__Fv,0
	nop
	call _g__Fv,0
	nop
	mov 0,%i0
	b,a L5
	b,a L5
L5:
	ret
	restore
	.align 4
	.proc 1
_try__Fcii:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	stb %i0,[%fp+71]
	st %i1,[%fp+72]
	st %i2,[%fp+76]
	ldub [%fp+71],%o0
	sll %o0,24,%o1
	sra %o1,24,%i0
	b,a L6
	b,a L6
	b,a L7
	b,a L6
L7:
L6:
	ret
	restore
	.align 4
	.proc 1
_try__Fici:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	st %i0,[%fp+68]
	stb %i1,[%fp+75]
	st %i2,[%fp+76]
	ld [%fp+68],%i0
	b,a L8
	b,a L8
L8:
	ret
	restore


///////////////////////////////////////////////////

and for g++ 2.3.3:


gcc2_compiled.:
.text
	.align 4
	.global _f__Fv
	.proc	020
_f__Fv:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	ld [%fp-20],%o0
	ld [%fp-24],%o2
	call _try,0
	nop
	st %o0,[%fp-32]
	b L2
	nop
	b L1
	nop
L2:
L1:
	ret
	restore
	.align 4
	.global _g__Fv
	.proc	020
_g__Fv:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	mov %o1,%o0
	ld [%fp-20],%o1
	ld [%fp-24],%o2
	call _try,0
	nop
	stb %o0,[%fp-26]
	b L4
	nop
	b L3
	nop
L4:
L3:
	ret
	restore
	.align 4
	.global _main
	.proc	04
_main:
	!#PROLOGUE# 0
	save %sp,-136,%sp
	!#PROLOGUE# 1
	call ___main,0
	nop
	call _f__Fv,0
	nop
	call _g__Fv,0
	nop
	mov 0,%i0
	b L5
	nop
	b L5
	nop
L5:
	ret
	restore
	.align 4
	.proc	04
_try:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	stb %i0,[%fp+71]
	st %i1,[%fp+72]
	st %i2,[%fp+76]
	ldub [%fp+71],%o0
	sll %o0,24,%o1
	sra %o1,24,%i0
	b L6
	nop
	b L6
	nop
	b L7
	nop
	b L6
	nop
L7:
L6:
	ret
	restore
	.align 4
	.proc	04
_try:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	st %i0,[%fp+68]
	stb %i1,[%fp+75]
	st %i2,[%fp+76]
	ld [%fp+68],%i0
	b L8
	nop
	b L8
	nop
L8:
	ret
	restore


/////////////////////////////////////////////////

-g for 2.3.3:

gcc2_compiled.:
.stabs "/users/mafia/oran/imagex/",100,0,0,Ltext0
.stabs "gnubug.c",100,0,0,Ltext0
.text
Ltext0:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.stabs "unknown type:t16=16",128,0,0,0
.stabs "__wchar_t:t17=r1;0;65535;",128,0,0,0
.stabs "$vtbl_ptr_type:T18=s8delta:6,0,16;index:6,16,16;pfn:19=*15,32,32;delta2:6,32,16;;",128,0,0,0
.stabs "$vtbl_ptr_type:t18",128,0,0,0
	.align 4
	.global _f__Fv
	.proc	020
_f__Fv:
.stabn 68,0,8,LM1
LM1:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
.stabn 68,0,9,LM2
LM2:
LBB2:
.stabn 68,0,11,LM3
LM3:
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	ld [%fp-20],%o0
	ld [%fp-24],%o2
	call _try,0
	nop
	st %o0,[%fp-32]
LBE2:
	b L2
	nop
	b L1
	nop
L2:
.stabn 68,0,12,LM4
LM4:
L1:
	ret
	restore
.stabs "f__Fv:F15",36,0,0,_f__Fv
.stabs "i:1",128,0,0,-20
.stabs "j:1",128,0,0,-24
.stabs "c:2",128,0,0,-25
.stabs "k:1",128,0,0,-32
.stabn 192,0,0,LBB2
.stabn 224,0,0,LBE2
	.align 4
	.global _g__Fv
	.proc	020
_g__Fv:
.stabn 68,0,15,LM5
LM5:
	!#PROLOGUE# 0
	save %sp,-128,%sp
	!#PROLOGUE# 1
.stabn 68,0,16,LM6
LM6:
LBB3:
.stabn 68,0,18,LM7
LM7:
	ldub [%fp-25],%o0
	sll %o0,24,%o2
	sra %o2,24,%o1
	mov %o1,%o0
	ld [%fp-20],%o1
	ld [%fp-24],%o2
	call _try,0
	nop
	stb %o0,[%fp-26]
LBE3:
	b L4
	nop
	b L3
	nop
L4:
.stabn 68,0,19,LM8
LM8:
L3:
	ret
	restore
.stabs "g__Fv:F15",36,0,0,_g__Fv
.stabs "i:1",128,0,0,-20
.stabs "j:1",128,0,0,-24
.stabs "c:2",128,0,0,-25
.stabs "k:2",128,0,0,-26
.stabn 192,0,0,LBB3
.stabn 224,0,0,LBE3
	.align 4
	.global _main
	.proc	04
_main:
.stabn 68,0,22,LM9
LM9:
	!#PROLOGUE# 0
	save %sp,-136,%sp
	!#PROLOGUE# 1
	call ___main,0
	nop
.stabn 68,0,23,LM10
LM10:
	call _f__Fv,0
	nop
	call _g__Fv,0
	nop
	mov 0,%i0
	b L5
	nop
	b L5
	nop
.stabn 68,0,24,LM11
LM11:
L5:
	ret
	restore
.stabs "main:F1",36,0,0,_main
	.align 4
	.proc	04
_try:
.stabn 68,0,3,LM12
LM12:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	stb %i0,[%fp+71]
	st %i1,[%fp+72]
	st %i2,[%fp+76]
.stabn 68,0,4,LM13
LM13:
	ldub [%fp+71],%o0
	sll %o0,24,%o1
	sra %o1,24,%i0
	b L6
	nop
	b L6
	nop
	b L7
	nop
	b L6
	nop
L7:
.stabn 68,0,5,LM14
LM14:
L6:
	ret
	restore
.stabs "try:f2",36,0,0,_try
.stabs "dummy:p2",160,0,0,71
.stabs "dd:p1",160,0,0,72
.stabs "i:p1",160,0,0,76
	.align 4
	.proc	04
_try:
.stabn 68,0,3,LM15
LM15:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	st %i0,[%fp+68]
	stb %i1,[%fp+75]
	st %i2,[%fp+76]
.stabn 68,0,4,LM16
LM16:
	ld [%fp+68],%i0
	b L8
	nop
	b L8
	nop
.stabn 68,0,5,LM17
LM17:
L8:
	ret
	restore
.stabs "try:f1",36,0,0,_try
.stabs "dummy:p1",160,0,0,68
.stabs "dd:p2",160,0,0,75
.stabs "i:p1",160,0,0,76

		Oran

Oran Singer                   Computer Science Lab
oran@Math.Tau.Ac.IL           School of Mathematics
oran@Taurus.BITNET            Tel Aviv University

Newsgroups: gnu.gcc.bug