Bug 24329 - spurious error?
spurious error?
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-01-18 20:25 EST by Dimitri Papadopoulos
Modified: 2007-04-18 12:30 EDT (History)
0 users

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


Attachments (Terms of Use)

  None (edit)
Description Dimitri Papadopoulos 2001-01-18 20:25:27 EST
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 05:38:23 EST
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 08:13:45 EST
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 07:43:36 EST
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.