This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
- To: nobody at gcc dot gnu dot org
- Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
- From: "Vincent Penquerc'h" <vincent at qubesoft dot com>
- Date: 8 Jun 2001 09:36:01 -0000
- Cc: gcc-prs at gcc dot gnu dot org,
- Reply-To: "Vincent Penquerc'h" <vincent at qubesoft dot com>
The following reply was made to PR c++/3063; it has been noted by GNATS.
From: "Vincent Penquerc'h" <vincent@qubesoft.com>
To: <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
Cc: <nobody@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
Date: Fri, 8 Jun 2001 10:28:21 +0100
Gabriel Dos Reis wrote:
> That is nonetheless an unfortunate workaround for a bug in the parser.
> Anyway, that is one of the things we plan to fix in the parser rewrite
> (soon).
Nice to hear that. 3.1 or later ?
Another thing that might be of interest is my original testcase, which
shows that the code is accepted when its body is inlined in the class
definition, but not when it is defined (still inline) outside of it.
The in-class verson compiles with 2.95, 2.95.3 and 3.0, the out-of-class
version compiles with GCC 2.95, but not with 2.95.3 nor CodeSourcery's web
GCC 3.0 compiler. I did not try those with 2.95.1 nor 2.95.2.
I was told it was because trying to overload on the return value, which
is not allowed, but since I explicitely qualify the template arguments,
there is no need for resolution. Even if this code is not valid, I'd be
tempted to say that this discrepancy is a compiler bug, and I'd like to
know what you GCC C++ hackers think of it.
Thanks for your help
class Rep {
public:
template<class Res> inline const Res* Get() const;// {return 0;}
};
class Manager {
Rep rep;
public:
template<class Res> const Res *Get() const;// {return rep.Get<Res>();}
};
#if 1
template<class Res> inline const Res* Rep::Get() const
{
return 0;
}
template<class Res> const Res *Manager::Get() const
{
return rep.Get<Res>();
}
#endif
class Res {};
int main()
{
Manager m;
m.Get<Res>();
return 0;
}
--
Vincent Penquerc'h