Bug 24329
| Summary: | spurious error? | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Dimitri Papadopoulos Orfanos <dimitri.papadopoulos> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED RAWHIDE | QA Contact: | David Lawrence <dkl> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.0 | Keywords: | FutureFeature |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i686 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| 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: | --- | Target Upstream Version: | |
| Embargoed: | |||
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).
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... 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. |
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.