Article View: gnu.g++.bug
Article #1030g++2.2.2 - const template member functions
From: David J Dawkins
Date: Tue, 06 Oct 1992 11:23
Date: Tue, 06 Oct 1992 11:23
49 lines
1817 bytes
1817 bytes
Problem with 'const' member function templates
> template<class T>
> struct A {
> void foo() const;
> };
>
> template<class T>
> void
> A<T>::foo() const
> {}
>
>
> main()
> {
> A<int> a;
>
> a.foo();
> }
The AT&T 3.0 compiler copes with this fine.
The G++ 2.2.2 compiler gives the following error:
t.c:4: template for method `foo' doesn't match any in class `A<int>'
Without the 'const' specifier, member function specifier, both compilers cope with it fine.
-- Compilation details -------------------------------
valhalla% g++ -v t.c
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/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 t.c /usr/tmp/cca03267.i
GNU CPP version 2.2.2 (sparc)
/usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca03267.i -quiet -dumpbase t.cc -version -o /usr/tmp/cca03267.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
t.c: In function `int main ()':
t.c:4: template for method `foo' doesn't match any in class `A<int>'
valhalla% uname -a
SunOS valhalla 4.1.1 1 sun4c
-dave
--
djd@csg.cs.rdg.ac.uk
djd@csug.cs.rdg.ac.uk
davidd@integ.uucp
Technical Details
Message-ID:
<9210061123.AA03502@csg.cs.reading.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!uk.ac.reading.CS.CSg!djdShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!uk.ac.reading.CS.CSg!djd From: djd@uk.ac.reading.CS.CSg (David J Dawkins) Subject: g++2.2.2 - const template member functions Message-ID: <9210061123.AA03502@csg.cs.reading.ac.uk> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 6 Oct 1992 11:23:29 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 50