public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11664] New: Bad overload resolution in recursive template
@ 2003-07-24 20:43 igodard at pacbell dot net
2003-07-24 20:47 ` [Bug c++/11664] " igodard at pacbell dot net
2003-07-24 21:55 ` bangerth at dealii dot org
0 siblings, 2 replies; 3+ messages in thread
From: igodard at pacbell dot net @ 2003-07-24 20:43 UTC (permalink / raw)
To: gcc-bugs
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);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/11664] Bad overload resolution in recursive template
2003-07-24 20:43 [Bug c++/11664] New: Bad overload resolution in recursive template igodard at pacbell dot net
@ 2003-07-24 20:47 ` igodard at pacbell dot net
2003-07-24 21:55 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: igodard at pacbell dot net @ 2003-07-24 20:47 UTC (permalink / raw)
To: gcc-bugs
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
------- Additional Comments From igodard at pacbell dot net 2003-07-24 20:47 -------
Created an attachment (id=4476)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4476&action=view)
tst.cc - test case displaying bug
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/11664] Bad overload resolution in recursive template
2003-07-24 20:43 [Bug c++/11664] New: Bad overload resolution in recursive template igodard at pacbell dot net
2003-07-24 20:47 ` [Bug c++/11664] " igodard at pacbell dot net
@ 2003-07-24 21:55 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2003-07-24 21:55 UTC (permalink / raw)
To: gcc-bugs
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
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From bangerth at dealii dot org 2003-07-24 21:55 -------
This is not a bug: the declaration of the function in the derived class
hides the one in the base class. You can either use a using-declaration
in the derived class like
class T : public Mixin<T> {
public:
Mixin<T>::Bar;
void Foo(int i) {}
void Foo() {}
void Bar() {}
int i;
};
or qualify the use of the function:
t.Mixin<T>::Bar(1);
W.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-07-24 21:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-24 20:43 [Bug c++/11664] New: Bad overload resolution in recursive template igodard at pacbell dot net
2003-07-24 20:47 ` [Bug c++/11664] " igodard at pacbell dot net
2003-07-24 21:55 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).