This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/8271: Templates and pointers to const member functions
- From: René Møller Fonseca <fonseca at mip dot sdu dot dk>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 7 Jan 2003 19:26:01 -0000
- Subject: Re: c++/8271: Templates and pointers to const member functions
- Reply-to: René Møller Fonseca <fonseca at mip dot sdu dot dk>
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?= <fonseca@mip.sdu.dk>
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 <iostream>
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<class CLASS>
void mFunction(void (CLASS::* method)()) {
(o->*method)();
}
template<class CLASS>
void cFunction(void (CLASS::* method)() const) {
(o->*method)();
}
template<class CLASS>
void vFunction(void (CLASS::* method)() volatile) {
(o->*method)();
}
template<class CLASS>
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é