GCC incorrectly allows the following program: consteval int foo(){ struct A{char x;}; struct B{char y;}; struct C:A,B{}; char C::*p=&A::x; char B::*q=static_cast<char B::*>(p); C c{}; return((B&)c).*q; } int main(){ return foo(); } This program should be rejected since the static_cast has undefined behavior. The member x is neither in B, nor a class derived from B.
Almost an exact Dup. *** This bug has been marked as a duplicate of bug 109243 ***