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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs