This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11664] New: Bad overload resolution in recursive template
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jul 2003 20:43:25 -0000
- Subject: [Bug c++/11664] New: Bad overload resolution in recursive template
- 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=11664
Summary: Bad overload resolution in recursive template
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
Source code below gives error, not finding the declaration for Bar(int). But if the unrelated definition of Bar() is commented out then it does find it. This may be an example of the "known" problem with two-step template resolution, but I don't understand that problem and so can't tell. Problem also occurs in 3.0.4 (at least). Here follows the output of g++ -v, followed by test case source:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-3/configure --enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --without-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.2 20020927 (prerelease)
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/cpp0.exe -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D_X86_=1 -D_X86_=1 -Asystem=winnt -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D__tune_pentium2__ -D__tune_pentium3__ -D__stdcall=__attribute__((__stdcall__)) -D__fastcall=__attribute__((__fastcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_fastcall=__attribute__((__fastcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D__i386 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -isystem ../include/w32api -isystem ../../include/w32api tst.cc tst.ii
ignoring nonexistent directory "../include/w32api"
ignoring nonexistent directory "../../include/w32api"
GNU CPP version 3.2 20020927 (prerelease) (cpplib) (80386, BSD syntax)
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.2
/usr/include/c++/3.2/i686-pc-cygwin
/usr/include/c++/3.2/backward
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/cc1plus.exe -fpreprocessed tst.ii -quiet -dumpbase tst.cc -version -o tst.s
GNU CPP version 3.2 20020927 (prerelease) (cpplib) (80386, BSD syntax)
GNU C++ version 3.2 20020927 (prerelease) (i686-pc-cygwin)
compiled by GNU C version 3.2 20020927 (prerelease).
tst.cc: In function `int main()':
tst.cc:22: no matching function for call to `T::Bar(int)'
tst.cc:13: candidates are: void T::Bar()
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Bottom {};
template<typename Super, typename Sub = Bottom>
class Mixin : Sub {
Super* AsSuper() { return static_cast<Super*>(this); }
public:
void Bar(int i) { AsSuper()->Foo(i); }
};
class T : public Mixin<T> {
public:
void Foo(int i) {}
void Foo() {}
void Bar() {}
int i;
};
int main() {
T t;
t.Bar();
t.Bar(1);
t.Foo();
t.Foo(1);
}