[LLVMbugs] [Bug 19274] New: Inaccessible base not diagnosed in expression using the pointer-to-member operators

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 28 08:24:16 PDT 2014


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

            Bug ID: 19274
           Summary: Inaccessible base not diagnosed in expression using
                    the pointer-to-member operators
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: filip.roseen at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12307
  --> http://llvm.org/bugs/attachment.cgi?id=12307&action=edit
testcase.cpp

struct A { int a = 0; };
struct B : private A { };

int
main (int argc, char *argv[])
{
  int A::* ptr = &A::a;

  B ().*ptr; // ill-formed
}


----------------------------------------------------------------

The following should issue a diagnostic saying that our source is ill-formed,
`clang` however compiles and accepts it. `A` is not an accessible base of `B`,
therefore the line marked `// ill-formed` should error.

`gcc` shows the correct behaviour with the following diagnostic:

> testcase.cpp: In function ‘int main(int, char**)’:
> testcase.cpp:9:9: error: ‘A’ is an inaccessible base of ‘B’
>    B ().*ptr; // ill-formed



[expr.mptr.oper]p2 states the following:

  > The binary operator `.*` binds its second operand, which shall be
  > of type "pointer to member of T", to its first operand, which
  > shall be of class T or of a class of which T is an unambiguous and
  > accessible base class. The result is an object or a function of
  > the type specified by the second operand.



[ Note: the same applies to `->*` ]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140328/9bdff4ad/attachment.html>


More information about the llvm-bugs mailing list