Article View: gnu.g++.bug
Article #1286templates
From: Jarkko Sonninen
Date: Wed, 16 Dec 1992 21:56
Date: Wed, 16 Dec 1992 21:56
126 lines
3001 bytes
3001 bytes
compiling the following program causes error with assemler.
uname says system is SunOS hilja.it. 4.1.3 1 sun4c
I don't know templates or sparc assembly, but it seems to me that
g++ creates same name for all calls of template function.
Jarkko Sonninen
---
#include <iostream.h>
template <class t>
t max (t a, t b) (!
return (a > b ? a : b);
!)
void main() (!
cout << max (1, 2);
cout << max ('a', 'b');
!)
---
<hilja:222:~>g++ -v a.C
Reading specs from /net/aapo/scratch/kasper/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/specs
gcc version 2.3.2
/net/aapo/scratch/kasper/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/cpp -lang-c++ -v -I/net/aapo/scratch/kasper/lib/gcc-lib/include -I/net/aapo/scratch/kasper/lib/gcc-lib/g++-include -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix a.C /usr/tmp/cca18655.i
GNU CPP version 2.3.2 (sparc)
/net/aapo/scratch/kasper/lib/gcc-lib/sparc-sun-sunos4.1/2.3.2/cc1plus /usr/tmp/cca18655.i -quiet -dumpbase a.cc -version -o /usr/tmp/cca18655.s
GNU C++ version 2.3.2 (sparc) compiled by GNU C version 2.3.2.
a.C:8: warning: return type for `main' changed to integer type
as -o /usr/tmp/cca186551.o /usr/tmp/cca18655.s
as: "/usr/tmp/cca18655.s", line 69: error: redefinition of symbol "_max"
/net/aapo/scratch/kasper/bin/gcc-sparc-sun-sunos4.1: /usr/tmp/cca186551.o: No such file or directory
---
gcc2_compiled.:
.text
.align 4
.global _main
.proc 04
_main:
!#PROLOGUE# 0
save %sp,-136,%sp
!#PROLOGUE# 1
call ___main,0
nop
mov 1,%o0
mov 2,%o1
call _max,0
nop
mov %o0,%o1
sethi %hi(_cout),%o2
or %o2,%lo(_cout),%o0
call ___ls__7ostreami,0
nop
mov 97,%o0
mov 98,%o1
call _max,0
nop
sll %o0,24,%o2
sra %o2,24,%o1
sethi %hi(_cout),%o2
or %o2,%lo(_cout),%o0
call ___ls__7ostreamc,0
nop
mov 0,%i0
b L230
nop
b L230
nop
L230:
ret
restore
.align 4
.proc 04
_max:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
stb %i0,<(%fp+71)>
stb %i1,<(%fp+75)>
ldub <(%fp+71)>,%o0
sll %o0,24,%o2
sra %o2,24,%o1
ldub <(%fp+75)>,%o2
sll %o2,24,%o3
sra %o3,24,%o2
cmp %o1,%o2
bge L232
nop
ldub <(%fp+75)>,%o0
L232:
sll %o0,24,%o0
sra %o0,24,%i0
b L231
nop
b L231
nop
L231:
ret
restore
.align 4
.proc 04
_max:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
st %i0,<(%fp+68)>
st %i1,<(%fp+72)>
ld <(%fp+68)>,%o0
ld <(%fp+72)>,%o1
cmp %o0,%o1
bge L234
nop
ld <(%fp+72)>,%o0
L234:
mov %o0,%i0
b L233
nop
b L233
nop
L233:
ret
restore
Technical Details
Message-ID:
<199212161756.AA18715@hilja.it.lut.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lut.fi!Jarkko.SonninenShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lut.fi!Jarkko.Sonninen From: Jarkko.Sonninen@lut.fi (Jarkko Sonninen) Subject: templates Message-ID: <199212161756.AA18715@hilja.it.lut.fi> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 16 Dec 1992 21:56:50 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 127