https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103552
Bug ID: 103552 Summary: Compile-time comparison of subobject and parent class Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- This program: ``` struct A{}; struct B : A { A a; }; int main() { constexpr B b{}; static_assert( &static_cast<const A&>(b) < &b.a ); } ``` is accepted by GCC, but Clang rejects it with the error: ``` comparison of address of base class subobject 'A' of class 'B' to field 'a' has unspecified value ``` Demo: https://gcc.godbolt.org/z/9G8szToPz It looks like Clang is right here, and this indeed must be rejected.