---Offending Code---
#include <iostream>
class Foo
{
};
class Bar
{
};
template<class A>
class Handler
{
public:
virtual void handle(A*) = 0;
};
class Baz : public Handler<Foo>,
public Handler<Bar>
{
};
class Foobar : public Baz
{
public:
virtual void handle(Bar* bar)
{
std::cout << "handle bar" << std::endl;
}
virtual void handle(Foo* foo)
{
std::cout << "handle foo" << std::endl;
}
};
int main()
{
Foo* foo = new Foo();
Baz* baz = new Foobar();
baz->handle(foo);
return 0;
}
--- compilation command ---
g++ test.cpp
--- compiler error ---
test.cpp: In function int main():
test.cpp:45: error: request for member handle is ambiguous
test.cpp:18: error: candidates are: void Handler<A>::handle(A*) [with A = Bar]
test.cpp:18: error: void Handler<A>::handle(A*) [with A = Foo]
--- notes ---
This error doesn't happen if Foobar doesn't exist and the interfaces are
implemented in Baz.
--
Summary: erroneous ambiguous error for subclasses overloaded
templated interfaces
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: a dot clarke at techsmith dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36641