This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13270] Failed compile of template function in template class called from another template
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2003 12:57:30 -0000
- Subject: [Bug c++/13270] Failed compile of template function in template class called from another template
- References: <20031202121116.13270.Mark.Hodson@dsto.defence.gov.au>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From giovannibajo at libero dot it 2003-12-02 12:57 -------
Your code is invalid, you should use:
Set s(Test<Allocator>::template MakeSet<Set>(a));
"template" keyword is needed when naming a dependent template-id in a postfix-
expression within a template definition.
Delegalising this, the compiler needs to know that "MakeSet" is a template to
be able to understand that the following "<" is the start of a template
argument list (otherwise, it's just a minor sign). But the compiler cannot find
it out at parsing time because Test<Allocator> depends on the template
parameter "Allocator", which is unknown until instantiation. You could have
some specializations in which Test<Allocator>::MakeSet is an enum, for instance.
By adding the template keyword, you tell the parser that MakeSet, in that
context, is and always be a template.
By the way, 2 days ago GCC 3.4 was updated to provide a helpful error message
describing this problem. I suggest you to update the compiler and try again to
see the new error message.
Nonetheless, the code is invalid and correctly rejected by GCC.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13270