This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23982] New: gcc tries to call global function instead of base template's method
- From: "mmarek at suse dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2005 16:38:09 -0000
- Subject: [Bug c++/23982] New: gcc tries to call global function instead of base template's method
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code works with previous versions of gcc (tried "3.3.5
20050117" and "4.0.2 20050901"), but fails to compile with "4.1.0
20050919". It works if Base and Derived aren't templates and it works
if I call this->func(t) (which is a simple workaround).
------8<-----------------
int func(const char*);
class Test {
int i1, i2;
};
template <class T>
class Base {
public:
void func(T &t) { };
};
template <class T>
class Derived : public Base<T> {
public:
void call_func(T &t) {
#if 1
func(t);
#else
this->func(t);
#endif
};
};
int main()
{
Derived<Test> d;
Test t;
d.call_func(t);
return 0;
}
------8<-----------------
$ g++ -Wall scope.cc
scope.cc: In member function ‘void Derived<T>::call_func(T&) [with T = Test]’:
scope.cc:30: instantiated from here
scope.cc:18: error: cannot convert ‘Test’ to ‘const char*’ for argument ‘1’ to
‘int func(const char*)’
$ g++ -v
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man
--libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,f95,java,ada --enable-checking
--with-gxx-include-dir=/usr/include/c++/4.1.0 --disable-libssp
--enable-java-awt=gtk --disable-libjava-multilib --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit
--without-system-libunwind --host=i586-suse-linux
Thread model: posix
gcc version 4.1.0 20050919 (experimental) (SUSE Linux)
PS: Sorry if this isn't a bug, I'm not that experienced in C++...
--
Summary: gcc tries to call global function instead of base
template's method
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mmarek at suse dot cz
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23982