[Bug c++/14790] New: C++: ambigous overload compile failure - new case different from 1675

osf at squirrely dot net gcc-bugzilla@gcc.gnu.org
Tue Mar 30 23:45:00 GMT 2004


/*
 * gpp overloading bug report
 *
 * frank m spies        osf@squirrely.net
 *
 *
 * this was tested with g++ 2.96 on an sun ultra sparc and 3.3.1 (cygwin) on
 * an amd athlon running win2k sp4
 * no options used .. just straight
 * g++ gpp_bug.cpp
 *
 * the compile error without the functions in final_derived are:

gpp_bug.cpp: In function `int main()':
gpp_bug.cpp:79: error: request for member `connect_to' is ambiguous
gpp_bug.cpp:39: error: candidates are: virtual void base2::connect_to(base2*)
gpp_bug.cpp:31: error:                 virtual void base1::connect_to(base1*)

 * with the functions in final_derived it compiles just fine
 *
 * this is a bug to me because even though the two base classes have the same
 * member function name the parameters given are of completely different type
 * not even sharing a base class. though even if they share a base class it
 * should still choose the right one.
 */

class   base1
{
public:
virtual void    connect_to(base1*)
{
}
};

class   base2
{
public:
virtual void    connect_to(base2*)
{
}
};

class   derived1 : public base1
{
public:
};

class   derived2 : public base2
{
public:
};

class   final_derived : public derived1, public derived2
{
public:
/**
 * comment these 2 functions out to get a compile error
 *
virtual void    connect_to(base1*)
{
}
virtual void    connect_to(base2*)
{
}
**
 * comment out from up there to down here to get the compile error
 *
 * if you leave those 2 functions in it compiles fine (workaround but painful)
 * if you take them out it does not compile
 *
 * tested under g++ 2.96 and 3.3.1 (cygwin)
 */
};


main()
{
        final_derived fd;
        fd.connect_to(new derived1());
}

-- 
           Summary: C++: ambigous overload compile failure - new case
                    different from 1675
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: osf at squirrely dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14790



More information about the Gcc-bugs mailing list