public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8271: Templates and pointers to const member functions
@ 2003-01-07 20:05 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-01-07 20:05 UTC (permalink / raw)
  To: bangerth, gcc-bugs, gcc-prs, nobody

Synopsis: Templates and pointers to const member functions

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Jan  7 12:05:32 2003
State-Changed-Why:
    Rene analyzed this to be a bug indeed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8271


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/8271: Templates and pointers to const member functions
@ 2003-01-07 19:26 René Møller Fonseca
  0 siblings, 0 replies; 3+ messages in thread
From: René Møller Fonseca @ 2003-01-07 19:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2203 bytes --]

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é
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/8271: Templates and pointers to const member functions
@ 2002-10-17 15:26 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2002-10-17 15:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8271
>Category:       c++
>Synopsis:       Templates and pointers to const member functions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 17 15:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
>Organization:
>Environment:
all gcc versions since at least 2.95
>Description:
The following code compiles with gcc:
-------------------------------------------
struct X { void f () const; };

template <class T> void g(void (T::*) ());

void h () {  g (&X::f);  };
-------------------------------------------
On the other hand, it fails to compile with at least two 
other compilers, which made me wonder who's right and who
is wrong. The point is that the template function g takes
a member function pointer, but we pass a pointer to a
_const_ member function. gcc does what seems very
reasonable,namely identifying the template argument T with
"const X". However, other compilers do not do this. They
say there is no prototype for an argument 
'void (T::*)() const'.

I tried to find normative statements in the standard, but
could not find anything that would match my case, which is
probably only due to an incomplete search through the
standard.

So, I would be happy about a statement by someone more
knowledgeable about this than me :-)

Thanks
  Wolfgang
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-07 20:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-07 20:05 c++/8271: Templates and pointers to const member functions bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-01-07 19:26 René Møller Fonseca
2002-10-17 15:26 bangerth

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).