This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
egcs-1.0.2, egcs-980315 and templates
- To: egcs at cygnus dot com
- Subject: egcs-1.0.2, egcs-980315 and templates
- From: Andrew Pollard <andrew at odie dot demon dot co dot uk>
- Date: Thu, 19 Mar 1998 18:32:40 GMT
Hi,
I'm not sure if this is an egcs specific thing or just my
misunderstanding of the latest C++ spec, but the following code
snippet (which was created from a much larger bit of our source code)
has problems with egcs-980315..
-------------------------------------------------------------------------------
template<class K>
struct A {
int foo(const K&);
int bar(const K&);
};
template<class K>
int
A<K>::bar(const K& k)
{
#if PROBLEM
return(foo(k));
#else
return(0);
#endif
}
#if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 90)
template<>
#endif
int
A<const char*>::foo(const char*const& k)
{
return((int)k);
}
-------------------------------------------------------------------------------
It compiles fine with egcs-1.0.2 and gcc-2.7.2.2, but with
% gcc -v
Reading specs from /usr/egcs/usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.14/specs
gcc version egcs-2.91.14 980315 (gcc-2.8.0 release)
% g++ -DPROBLEM -c f.cc
f.cc:23: specialization of A<const char *>::foo<const char *>(const char *const &) after instantiation
f.cc:23: explicit specialization of A<const char *>::foo<const char *>(const char *const &) after first use
but without the -DPROBLEM it compiles
(It compiles with both in egcs-1.0.2 and gcc-2.7.2.2 as well).
>From what I could understand from the draft C++ spec, I can't see why
the call to foo(k) in A::bar should instantiate the template and hence
make the specialization invalid.
Can someone tell me what I am missing here?
Cheers,
Andrew.
--
Andrew Pollard, Auto Simulations Ltd. UK. | home: andrew@odie.demon.co.uk
2 Milbanke Court, Milbanke Way, Bracknell | work: andrewp@autosim.com
Tel:+44(0)1344 426486x103 Fax:+44(0)1344 426615 | http://www.odie.demon.co.uk