https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98122
Bug ID: 98122 Summary: [regression] Accessing union member through pointer-to-member is not a constant expression Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m.cencora at gmail dot com Target Milestone: --- Following code does not compile on gcc-10 and newer in all std C++14-20 modes. This used to work in gcc-9 and earlier. union foo { int a; }; constexpr bool test() { foo f{ .a = 42 }; constexpr auto memPtr = &foo::a; return (f.*memPtr) == 42; } // error: accessing value of 'f' through a 'int' glvalue in a constant expression // return (f.*memPtr) == 42; static_assert(test(), "");