This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12169] New: False ambiguity in overloaded members from different base classes
- From: "preusser at ite dot inf dot tu-dresden dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Sep 2003 16:15:51 -0000
- Subject: [Bug c++/12169] New: False ambiguity in overloaded members from different base classes
- 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=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");
}