🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1404

failure to munge template function name

#1404
From: Marvin Solomon
Date: Sat, 23 Jan 1993 02:47
123 lines
2781 bytes
// Problem with template functions in  g++ version 2.3.3
// The compiler appears to be forgetting to munge the names of the functions
// it generates for version of g (they are both called "g").  Needless to say,
// the assembler is not very happy about it.  Under Ultrix, the message is
//
// as0: Error: bug3.c, line 10: .ent must precede the definition of the symbol g
// as0: Error: bug3.c, line 10: Conflicting definition of symbol g
//
// (twice).  The generated assembly code is reproduced below.  Note the
// two copies of "g": one that calls O__Fc and one that calls O__Fi.

void O(char);
void O(int);

template <class Arg>
class Template {
public:
	Arg i;
};

template <class Arg> void g(Template<Arg> &x) { O(x.i); }

void f() {
	Template<int> ti;
	Template<char> tc;
	g(ti);
	g(tc);
}

/*
	.file	1 "bug3.c"

 # GNU C++ 2.3.3 [AL 1.1, MM 33] DECstation running ultrix compiled by GNU C

 # Cc1 defaults:

 # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
 # -quiet -dumpbase -o

gcc2_compiled.:
	.text
	.align	2
	.globl	f__Fv

	.loc	1 22
	.ent	f__Fv
f__Fv:
	.frame	$fp,32,$31		# vars= 8, regs= 2/0, args = 16, extra= 0
	.mask	0xc0000000,-4
	.fmask	0x00000000,0
	subu	$sp,$sp,32
	sw	$31,28($sp)
	sw	$fp,24($sp)
	move	$fp,$sp
	addu	$4,$fp,16
	jal	g
	addu	$2,$fp,20
	move	$4,$2
	jal	g
	j	$L2
	j	$L1
$L2:
$L1:
	move	$sp,$fp			# sp not trusted here
	lw	$31,28($sp)
	lw	$fp,24($sp)
	addu	$sp,$sp,32
	j	$31
	.end	f__Fv
	.align	2

	.loc	1 20
	.ent	g
g:
	.frame	$fp,24,$31		# vars= 0, regs= 2/0, args = 16, extra= 0
	.mask	0xc0000000,-4
	.fmask	0x00000000,0
	subu	$sp,$sp,24
	sw	$31,20($sp)
	sw	$fp,16($sp)
	move	$fp,$sp
	sw	$4,24($fp)
	lw	$2,24($fp)
	lb	$3,0($2)
	move	$4,$3
	jal	O__Fc
	j	$L4
	j	$L3
$L4:
$L3:
	move	$sp,$fp			# sp not trusted here
	lw	$31,20($sp)
	lw	$fp,16($sp)
	addu	$sp,$sp,24
	j	$31
	.end	g
	.align	2

	.loc	1 20
	.ent	g
g:
	.frame	$fp,24,$31		# vars= 0, regs= 2/0, args = 16, extra= 0
	.mask	0xc0000000,-4
	.fmask	0x00000000,0
	subu	$sp,$sp,24
	sw	$31,20($sp)
	sw	$fp,16($sp)
	move	$fp,$sp
	sw	$4,24($fp)
	lw	$2,24($fp)
	lw	$4,0($2)
	jal	O__Fi
	j	$L6
	j	$L5
$L6:
$L5:
	move	$sp,$fp			# sp not trusted here
	lw	$31,20($sp)
	lw	$fp,16($sp)
	addu	$sp,$sp,24
	j	$31
	.end	g
*/
Technical Details
Message-ID: <9301222119.AA17515@gjetost.cs.wisc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.wisc.edu!solomon

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.wisc.edu!solomon
From: solomon@cs.wisc.edu (Marvin Solomon)
Newsgroups: gnu.g++.bug
Subject: failure to munge template function name
Date: 22 Jan 1993 21:47:04 -0500
Organization: GNUs Not Usenet
Lines: 124
Sender: daemon@cis.ohio-state.edu
Approved: bug-g++@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9301222119.AA17515@gjetost.cs.wisc.edu>