Issue |
150709
|
Summary |
[clang] Accepts ill-formed program containing function call via member pointer to member in sibling class during constant evaluation
|
Labels |
clang
|
Assignees |
|
Reporter |
keinflue
|
Clang accepts the following C++ program that is ill-formed (see https://godbolt.org/z/hGooP8MxY)
```
struct A { };
struct B : A { };
struct C : A {
constexpr void foo() {}
};
consteval void test() {
auto p = &C::foo;
auto q = static_cast<void (A::*)()>(p);
B b;
A& a = b;
(a.*q)();
}
int main() { test(); }
```
The program should be ill-formed, because the most derived object `b` does not contain the member `C::foo` which the member pointer `a` references, causing the call to have undefined behavior.
This is a variation of https://github.com/llvm/llvm-project/issues/150705 with the `virtual` keyword removed, which instead causes a crash.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs