[LLVMbugs] [Bug 13235] New: terrible diagnostic text taking address of bound member function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 28 19:36:24 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13235

             Bug #: 13235
           Summary: terrible diagnostic text taking address of bound
                    member function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This snippet comes from test/SemaCXX/member-pointer.cpp, so we really have no
excuse:

namespace pr5985 {
  struct c {
    void h();
    void f() {
      void (c::*p)();
      p = &h; // expected-error {{must explicitly qualify}}
      p = &this->h; // expected-error {{cannot create a non-constant pointer to
member function}}
      p = &(*this).h; // expected-error {{cannot create a non-constant pointer
to member function}}
    }
  };
}

What is this "non-constant" nonsense? The error is that we're trying to create
a pointer to a bound member function. Look at what GCC says on the same
snippet:

z.cc: In member function ‘void pr5985::c::f()’:
z.cc:6: error: ISO C++ forbids taking the address of an unqualified or
parenthesized non-static member function to form a pointer to member function. 
Say ‘&pr5985::c::h’
z.cc:7: error: ISO C++ forbids taking the address of a bound member function to
form a pointer to member function.  Say ‘&pr5985::c::h’
z.cc:8: error: ISO C++ forbids taking the address of an unqualified or
parenthesized non-static member function to form a pointer to member function. 
Say ‘&pr5985::c::h’

That's better. GCC even includes a "fixit".

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list