[Bug c++/12169] New: False ambiguity in overloaded members from different base classes
preusser at ite dot inf dot tu-dresden dot de
gcc-bugzilla@gcc.gnu.org
Thu Sep 4 16:15: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=12169
Summary: False ambiguity in overloaded members from different
base classes
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: preusser at ite dot inf dot tu-dresden dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
The G++ compiler complains about an alleged ambiguity when two members with the
same names but differing signatures are inherited from two different base classes.
Workaround: Implementing forwarding methods in the subclass.
Example:
#include <iostream>
using namespace std;
class A {
public:
void add(unsigned u, unsigned c) { cout << u << endl; }
};
class B {
public:
void add(char const* c) { cout << c << endl; }
};
class C : public A, public B {};
int main() {
C c;
c.add(7, 5);
c.add("abc");
}
More information about the Gcc-bugs
mailing list