[Bug c++/12311] New: Cannot resolve template methods properly
davidcrowley at comcast dot net
gcc-bugzilla@gcc.gnu.org
Wed Sep 17 03:01:00 GMT 2003
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 =================
More information about the Gcc-bugs
mailing list