From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16852 invoked by alias); 7 Jan 2003 19:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 16838 invoked by uid 71); 7 Jan 2003 19:26:01 -0000 Date: Tue, 07 Jan 2003 19:26:00 -0000 Message-ID: <20030107192601.16837.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= Subject: Re: c++/8271: Templates and pointers to const member functions Reply-To: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= X-SW-Source: 2003-01/txt/msg00461.txt.bz2 List-Id: The following reply was made to PR c++/8271; it has been noted by GNATS. From: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, bangerth@ticam.utexas.edu, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/8271: Templates and pointers to const member functions Date: Tue, 07 Jan 2003 20:18:51 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8271 Hi, It is GCC that is wrong. The qualifiers are part of the type and must not be ignored. Here is a more elaborate implementation. >>>>>> #include using namespace std; class MyClass { public: void mutableMethod() throw() { cout << __func__ << endl; } void constMethod() const throw() { cout << __func__ << endl; } void volatileMethod() volatile throw() { cout << __func__ << endl; } void constVolatileMethod() const volatile throw() { cout << __func__ << endl; } }; MyClass* o = new MyClass(); template void mFunction(void (CLASS::* method)()) { (o->*method)(); } template void cFunction(void (CLASS::* method)() const) { (o->*method)(); } template void vFunction(void (CLASS::* method)() volatile) { (o->*method)(); } template void cvFunction(void (CLASS::* method)() const volatile) { (o->*method)(); } int main() { // cFunction(&MyClass::mutablemethod); // ERROR cFunction(&MyClass::constMethod); // OK mFunction(&MyClass::mutableMethod); // OK mFunction(&MyClass::constMethod); // ERROR - GCC bug // vFunction(&MyClass::volatileMethod); // ERROR vFunction(&MyClass::volatileMethod); // OK mFunction(&MyClass::constVolatileMethod); // ERROR - GCC bug cFunction(&MyClass::constVolatileMethod); // ERROR - GCC bug vFunction(&MyClass::constVolatileMethod); // ERROR - GCC bug cvFunction(&MyClass::constVolatileMethod); // OK return 0; } <<<< The generated output (using GCC-3.2): constMethod mutableMethod constMethod volatileMethod constVolatileMethod constVolatileMethod constVolatileMethod constVolatileMethod cheers, René