https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113599
Bug ID: 113599 Summary: Wrong computation of member offset through pointer-to-member Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: simon.marchi at polymtl dot ca Target Milestone: --- This commit: c++: non-dependent .* operand folding [PR112427] https://gitlab.com/gnutools/gcc/-/commit/d3f48f68227 seems to cause a regression in some cases when computing the address of a member using a pointer-to-member. Origin: https://sourceware.org/bugzilla/show_bug.cgi?id=31281 I made this reproducer, which was then made more minimal by Tom de Vries. We get the address of the thread_info::node field in two different ways. One using through a pointer-to-member, the other is getting its address directly. We expect both to be equal. gcc 14/trunk gets it wrong. ... struct intrusive_list_node { void *next; }; struct dummy { void *base; }; struct thread_info : public dummy, public intrusive_list_node { intrusive_list_node node; }; static thread_info ti; int main (void) { auto thread_info::*MemberNode = &thread_info::node; auto node_ptr_1 = &(ti.*MemberNode); auto node_ptr_2 = &ti.node; return !(node_ptr_1 == node_ptr_2); } ... gcc-13: ... $ g++ test.cpp; ./a.out; echo $? 0 ... gcc-14: ... $ g++ test.cpp; ./a.out; echo $? 1 ...