https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118923
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=118856 Status|UNCONFIRMED |NEW Last reconfirmed| |2025-02-18 Ever confirmed|0 |1 CC| |jason at gcc dot gnu.org, | |ppalka at gcc dot gnu.org --- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> --- Seems to have started with r15-7508 "c++: -frange-for-ext-temps and reused temps [PR118856]". Reduced runtime testcase: struct A { int x[3]; int* begin() { return x; } int* end() { return x+3; } }; struct Workspace { A previousRestrictedMoveArea() { return {1,2,3}; } A restrictedMoveArea() { return {1,2,3}; } bool inRearrange() { return m_inRearrange; } bool m_inRearrange = false; static Workspace _self; }; Workspace Workspace::_self; inline Workspace *workspace() { return &Workspace::_self; } void foo() { auto moveAreaFunc = workspace()->inRearrange() ? &Workspace::previousRestrictedMoveArea : &Workspace::restrictedMoveArea; for (const int &r : (workspace()->*moveAreaFunc)()) { } } int main() { foo(); }