From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19808 invoked by alias); 8 Sep 2004 21:33:08 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 19800 invoked from network); 8 Sep 2004 21:33:07 -0000 Received: from unknown (HELO service.sh.cvut.cz) (147.32.127.214) by sourceware.org with SMTP; 8 Sep 2004 21:33:07 -0000 Received: from localhost (localhost [127.0.0.1]) by service.sh.cvut.cz (Postfix) with ESMTP id AAA081A3C79; Wed, 8 Sep 2004 23:33:06 +0200 (CEST) Received: from service.sh.cvut.cz ([127.0.0.1]) by localhost (service [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05250-06; Wed, 8 Sep 2004 23:33:04 +0200 (CEST) Received: from logout.sh.cvut.cz (logout.sh.cvut.cz [147.32.127.203]) by service.sh.cvut.cz (Postfix) with ESMTP id 25EA61A3C9D; Wed, 8 Sep 2004 23:33:02 +0200 (CEST) Received: from logout (logout [147.32.127.203]) by logout.sh.cvut.cz (Postfix) with ESMTP id 5B7B53C31D; Wed, 8 Sep 2004 23:33:08 +0200 (CEST) Date: Wed, 08 Sep 2004 21:33:00 -0000 From: Vaclav Haisman To: Simon MARTIN Cc: gcc@gcc.gnu.org Subject: Re: Type problem with template functions and inheritance ? In-Reply-To: <200409082211.28678.simartin@users.sourceforge.net> Message-ID: <20040908233105.B16173@logout.sh.cvut.cz> References: <200409082211.28678.simartin@users.sourceforge.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at sh.cvut.cz X-SW-Source: 2004-09/txt/msg00396.txt.bz2 Because Comeau's test drive compiler accepts I would fill a bug report in Bugzilla if I were you. VH On Wed, 8 Sep 2004, Simon MARTIN wrote: > Hello. > > I played a little with templates and template functions, and I encountered a > problem with GCC while doing so. The code at the end of this message builds > with Microsoft's Visual C++ Toolkit 2003, but fails with GCC. Since the code > is quite "weird", I wonder whether there's a problem in GCC or Visual is too > laxist. > > What is strange is: > - the "" in the error message > - the fact that if I "help" GCC a little (before the first static_cast), > then things work fine. > > Thanks in advance for your help / explanation. > > Regards, > Simon > > [simon@texel gcc_test]$ g++ -v > Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.2/specs > Configured with: ../configure --prefix=/usr --libdir=/usr/lib > --with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info > --enable-shared --enable-threads=posix --disable-checking --enable-long-long > --enable-__cxa_atexit --enable-clocale=gnu > --enable-languages=c,c++,ada,f77,objc,java,pascal > --host=i586-mandrake-linux-gnu --with-system-zlib > Thread model: posix > gcc version 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk) > > [simon@texel gcc_test]$ g++ -Wall -o test test.cpp > test.cpp: In function `int main(int, char**)': > test.cpp:18: error: invalid static_cast from type `' to type > `bool (Base::*)(const char*)' > > ==== test.cpp > class Base {}; > struct MyClass : public Base > { > template bool Method(const char *value) { return true; } > }; > > int main(int argc, char *argv[]) > { > typedef bool (Base::*BaseMethodPtr)(const char*); > typedef bool (MyClass::*MethodPtr)(const char*); > > MyClass aClass; > > MethodPtr mp = &MyClass::Method<1>; > BaseMethodPtr p1 = static_cast(mp); > (aClass.*p1)("One"); > > BaseMethodPtr p2 = static_cast(&MyClass::Method<1>); > (aClass.*p2)("OneAgain"); > > return 0; > } > ==== end of test.cpp > > -- > Kile - an Integrated LaTeX Environment for KDE > http://kile.sourceforge.net >