This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug report: egcs 1.1
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Bug report: egcs 1.1
- From: Harald Winroth <harald at nada dot kth dot se>
- Date: Sun, 28 Feb 1999 15:34:35 +0100
- Organization: Royal Institute of Technology Stockholm
This bug report concerns member function pointers to overloaded
functions.
The bug is not present in gcc 2.8.1.
Best regards
Harald Winroth
CS Dept.
Royal Institute of Technolgy, Stockholm.
$ g++ -v --save-temps bug.cc
Reading specs from
/pkg/egcs/1.1.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
/pkg/egcs/1.1.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.60/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) bug.cc bug.ii
GNU CPP version egcs-2.91.60 19981201 (egcs-1.1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/pkg/egcs/1.1.1/include/g++
/usr/local/include
/pkg/egcs/1.1.1/sparc-sun-solaris2.5.1/include
/pkg/egcs/1.1.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.60/include
/usr/include
End of search list.
/pkg/egcs/1.1.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.60/cc1plus
bug.ii -quiet -dumpbase bug.cc -version -o bug.s
GNU C++ version egcs-2.91.60 19981201 (egcs-1.1.1 release)
(sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.91.57 19980901
(egcs-1.1 release).
bug.cc: In method `Foo::Foo()':
bug.cc:26: no matching function for call to `Function<Foo,int>::Function
(void (Foo::*)(string) const)'
bug.cc:26: candidates are: Function<Foo,int>::Function(const
Function<Foo,int> &)
bug.cc:11: Function<Foo,int>::Function<Foo, int>(void
(Foo::*)(int) const)
----- bug.cc -----
#include <string>
using namespace std;
// This class encapsulates a member function pointer
template<class C, class Arg>
class Function
{
public:
typedef void (C::*FuncPtr)(Arg) const;
Function(FuncPtr func_ptr) : func_ptr_(func_ptr) {}
private:
FuncPtr func_ptr_;
};
#if 1 // This compiles with gcc 2.8.1 but not with egcs 1.1.
// Class Foo contains two overloaded member functions called f.
// Two corresponding Function objects are created and initialized in
Foo's constructor.
// However, the egcs compiler fails to select the correct version of f.
struct Foo
{
void f(int) const {}
void f(string) const {}
Foo() {
Function<Foo, int> f1(&f);
Function<Foo, string> f2(&f);
}
};
#else // However, this works even with egcs 1.1.
struct Foo
{
void f(int) const {}
void f(string) const {}
Foo() {
Function<Foo, int> f1(&Foo::f);
Function<Foo, string> f2(&Foo::f);
}
};
#endif
int main()
{
Foo foo;
return 0;
}