Bug 24329 - spurious error?
Summary: spurious error?
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
(Show other bugs)
Version: 7.0
Hardware: i686 Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords: FutureFeature
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-01-19 01:25 UTC by Dimitri Papadopoulos
Modified: 2007-04-18 16:30 UTC (History)
0 users

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-15 12:43:42 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Dimitri Papadopoulos 2001-01-19 01:25:27 UTC
Hi,

Compile the following program using
	g++ -c <file>
on Red Hat 7.0 with latest gcc updates applied.

//----------------------------------------------------------------
class MyClass {
public:
  void MyClass::foo();
};

typedef void (MyClass::*MBF)();

void MyClass::mbf() {
  MBF f1 = &foo;            // THIS DOESN'T WORK
  MBF f2 = &MyClass::foo;   // THIS WORKS
}
//----------------------------------------------------------------

You'll get the following error message:
foo.cc: In method `void MyClass::foo ()':
foo.cc:9: ISO C++ forbids taking the address of a non-static member
function to form a pointer to member function.  Say `&MyClass::foo'

The error message is curious. Why can't I take the address of a 'member
function'
to form a pointer to a 'member function'? I couldn't find any explanation
about such
issues in the standard. Even if this is not a bug, consider improving the
message.

Comment 1 Jakub Jelinek 2001-01-19 10:38:23 UTC
Read [expr.unary.op]/3 which sais at the end:
Nor is &unqualified-id a pointer to member, even within the scope of
unqualified-id's class.
You can use
`-fms-extensions'
     Disable pedwarns about constructs used in MFC, such as implicit
     int and getting a pointer to member function via non-standard
     syntax.
switch though (see info gcc).

Comment 2 Dimitri Papadopoulos 2001-01-26 13:13:45 UTC
Hi,

Indeed I can disable the error message using `-fms-extensions' however
this is not the point.

My point is that the error message should be
	ISO C++ forbids taking the address of an unqualified member
	function to form a pointer to member function.
instead of
	ISO C++ forbids taking the address of a non-static member
	function to form a pointer to member function.

Sorry I wasn't clear enough in the first place. I was a bit lost as I was
struggling to find the relevant paragraph in the ISO C++ standard...


Comment 3 Jakub Jelinek 2001-02-15 12:43:36 UTC
I've changed it to
ISO C++ forbids taking the address of an unqualified non-static member
function to form a pointer to member function.
(both in my tree and in CVS head).
It will appear in gcc-c++-2.96-76.


Note You need to log in before you can comment on or make changes to this bug.