This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12311] New: Cannot resolve template methods properly
- From: "davidcrowley at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Sep 2003 02:53:27 -0000
- Subject: [Bug c++/12311] New: Cannot resolve template methods properly
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12311
Summary: Cannot resolve template methods properly
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: davidcrowley at comcast dot net
CC: gcc-bugs at gcc dot gnu dot org
When compiling the following code I get this error:
bug.cpp: In function `Z* getAs(D&) [with Z = A]':
bug.cpp:38: instantiated from here
bug.cpp:30: no matching function for call to `D::getAs()'
When compiling the templated getAs() function the compiler cant seem to resolve
the simple pass through call to the templated D::getAs() method. If I call the
templated D::getAs() method directly then it works fine.
command line: g++ bug.cpp
version: gcc 3.2.2
platform: RedHat 9.0 on i386
============ bug.cpp ==================
class A
{
};
class D : public A
{
public:
void *getAs(int)
{
return this;
}
template <typename T>
T* getAs()
{
return static_cast<T*>(getAs(0));
}
};
template <typename Z>
Z* getAs(D& d)
{
return d.getAs<Z>(); // no matching function
}
int
main()
{
D d;
A* a = d.getAs<A>(); // works
A* aa = getAs<A>(d); // fails
return 0;
}
============= end bug.cpp =================