[LLVMbugs] [Bug 10815] New: clang could help more when calling pointer-to-member function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 30 11:53:07 PDT 2011


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

           Summary: clang could help more when calling pointer-to-member
                    function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


This invalid program gives a diagnostic that could be better:

  struct X { void foo(); };
  void t() {
    X x;
    void (X::*y)() = &X::foo;
    x.*y();
  }

These member-pointer things are hard (though fortunately rare), so a good
compiler diagnostic would be really helpful. The error is:

x.cc:6:7: error: called object type 'void (X::*)()' is not a function or
      function pointer
  x.*y();
     ~^

while gcc gives me this:

x.cc: In function ‘void t()’:
x.cc:6: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘y
(...)’, e.g. ‘(... ->* y) (...)’

which actually showed me that I needed to insert the parens. Nice.

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