🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

G++ 2.3.3 and template functions doesn't compile

#1346
From: Olaf Heimburger
Date: Thu, 07 Jan 1993 09:28
46 lines
2234 bytes
Unfortunately, I had no chance to follow the discussion on this topic,
because I was off for three weeks and most of the postings in
gnu.g++.bug were expired.

Environment: SPARCstation 1, SunOS 4.1.1, gcc-2.3.3, binutils-2.0, libg++-2.3

I've just installed gcc 2.3.3 and tried a simple test program (see
below).  It compiled well but the assembler complained with an
``error: redefinition of symbol "_Max".''

Here is the output of the compiler call:

% g++ -v test.C
Reading specs from /usr/gnu/new/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/specs
gcc version 2.3.3
 /usr/gnu/new/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix test.C /usr/tmp/cca11442.i
GNU CPP version 2.3.3 (sparc)
 /usr/gnu/new/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cc1plus /usr/tmp/cca11442.i -quiet -dumpbase test.cc -version -o /usr/tmp/cca11442.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
 as -o /usr/tmp/cca114421.o /usr/tmp/cca11442.s
as: "/usr/tmp/cca11442.s", line 101: error: redefinition of symbol "_Max"
/usr/gnu/new/bin/gcc: /usr/tmp/cca114421.o: No such file or directory

And here is the test program:

#include <iostream.h>

template <class T>
T Max (T a, T b) {
    return (a < b) ? b : a;
}

main () {
    int a = 10, b = 9;
    float c = 100., d = 200.;
    cout << Max (a, b) << endl;
    cout << Max (c, d) << endl;
    return 0;
}

Regards,
--olaf

* Olaf Heimburger, H. Berthold AG, Software Development, Berlin (Germany)
* ...!unido!berthold!olafh <oheimburger@berthold.de> <olafh@berthold.de>
* VOICE: +49 30 7 79 54 64                             FAX: +49 30 7 79 55 05
Technical Details
Message-ID: <9301070728.AA11591@GECKO.berthold>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!berthold.DE!olafh

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!berthold.DE!olafh
From: olafh@berthold.DE (Olaf Heimburger)
Subject: G++ 2.3.3 and template functions doesn't compile
Message-ID: <9301070728.AA11591@GECKO.berthold>
Sender: gnulists@ai.mit.edu
Reply-To: oheimburger@berthold.de
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 7 Jan 1993 09:28:53 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 47