public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nuttygraphics at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/26988] New: template function in template class derived from virtual base can not be specialized Date: Sun, 02 Apr 2006 15:05:00 -0000 [thread overview] Message-ID: <bug-26988-12459@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 3804 bytes --] Given the following code: #define VIRTUAL virtual //#define VIRTUAL // use this to 'fix' the code #include <iostream> using namespace std; struct VirtualBase{}; struct Bar : public VIRTUAL VirtualBase { template< typename castT >explicit Bar( castT const& cast ); }; template< > Bar::Bar( int const & cast ) { cout << "Called Bar::Bar( int )!" << endl; } template< typename T > struct Hello : public VIRTUAL VirtualBase { Hello( int i ); }; template< > Hello< char >::Hello( int i ) { cout << "Called Hello::Hello( int )!" << endl; } template< typename T > struct Foo : public VIRTUAL VirtualBase { template< typename castT > Foo( castT const& cast ); template< typename T1 > void func( T1 ); }; template< > template< > Foo< char >::Foo( int const & cast ) { cout << "Called Foo::Foo( int )!" << endl; } int main() { Foo< char > fooChar( 42 ); Bar barChar( 42 ); Hello< char > helloChar( 42 ); return 0; } compiled with: g++ -v -save-temps main.cpp gives the following output Es werden eingebaute Spezifikationen verwendet. Ziel: i386-redhat-linux Konfiguriert mit: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux Thread-Modell: posix gcc-Version 4.0.2 20051125 (Red Hat 4.0.2-8) /usr/libexec/gcc/i386-redhat-linux/4.0.2/cc1plus -E -quiet -v -D_GNU_SOURCE main.cpp -fpch-preprocess -o main.ii nicht vorhandenes Verzeichnis »/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../i386-redhat-linux/include« wird ignoriert #include "..." - Suche beginnt hier: #include <...> - Suche beginnt hier: /usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2 /usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/i386-redhat-linux /usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/backward /usr/local/include /usr/lib/gcc/i386-redhat-linux/4.0.2/include /usr/include Ende der Suchliste. /usr/libexec/gcc/i386-redhat-linux/4.0.2/cc1plus -fpreprocessed main.ii -quiet -dumpbase main.cpp -auxbase main -version -o main.s GNU C++ version 4.0.2 20051125 (Red Hat 4.0.2-8) (i386-redhat-linux) compiled by GNU C version 4.0.2 20051125 (Red Hat 4.0.2-8). GGC-Heuristik: --param ggc-min-expand=99 --param ggc-min-heapsize=129465 main.cpp:18: Fehler: Template-ID »Bar<>« für »Bar::Bar(const int&)« passt zu keiner Templatedeklaration main.cpp:18: Fehler: ungültige Funktionsdeklaration main.cpp:55: Fehler: Template-ID »Foo<>« für »Foo<char>::Foo(const int&)« passt zu keiner Templatedeklaration main.cpp:55: Fehler: ungültige Funktionsdeklaration ======================================== The problem can be fixed, by putting the comment to the other #define at the beginning. I reproduced this on WinXP - gcc-3.4.2, Linux FC4 with gcc-4.0.0 and 4.0.2 However MSVC 7.1 + 8.0 and Comeau accept the code. -- Summary: template function in template class derived from virtual base can not be specialized Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: nuttygraphics at yahoo dot com GCC host triplet: LINUX FC4 and WinXP GCC target triplet: LINUX FC4 and WinXP http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26988
next reply other threads:[~2006-04-02 15:05 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-04-02 15:05 nuttygraphics at yahoo dot com [this message] 2006-04-02 16:21 ` [Bug c++/26988] template constructor " pinskia at gcc dot gnu dot org 2006-04-18 3:45 ` bangerth at dealii dot org 2006-05-25 2:47 ` mmitchel at gcc dot gnu dot org 2006-09-17 19:34 ` [Bug c++/26988] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org 2007-01-11 4:05 ` [Bug c++/26988] [4.0/4.1/4.2/4.3 " mmitchel at gcc dot gnu dot org 2007-02-03 16:45 ` gdr at gcc dot gnu dot org 2007-02-03 20:28 ` pinskia at gcc dot gnu dot org 2007-02-11 20:15 ` mmitchel at gcc dot gnu dot org 2007-02-11 21:41 ` mmitchel at gcc dot gnu dot org 2007-02-11 21:41 ` [Bug c++/26988] [4.0/4.1 " mmitchel at gcc dot gnu dot org 2007-02-14 9:10 ` mmitchel at gcc dot gnu dot org 2008-07-04 15:27 ` [Bug c++/26988] [4.1 " jsm28 at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-26988-12459@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).