https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116369
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|libstdc++ |c++ Ever confirmed|0 |1 Last reconfirmed| |2024-08-14 Target Milestone|--- |12.5 Known to fail| |9.1.0 Summary|[DEBUG MODE,C++20] access |[12/13/14/15 Regression] |to iterators from global |temporary variable bounded |empty container defined by |to const reference with |"const&" results in SIGSEGV |mutable field incorrectly | |marked as rodata Keywords| |wrong-code Status|UNCONFIRMED |NEW Known to work| |5.1.0, 7.1.0 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note I think there is a front-end (and a library) issue too. In libstdc++-v3/include/debug/safe_base.h we have: ``` /// The list of mutable iterators that reference this container _Safe_iterator_base* _M_iterators; /// The list of constant iterators that reference this container _Safe_iterator_base* _M_const_iterators; /// The container version number. This number may never be 0. mutable unsigned int _M_version; ``` The segfault is the store to _M_const_iterators. Which should have been marked as mutable but since _M_version is marked as mutable the temporary variable should NOT have gone in rodata anyways. Reduced testcase for the front-end issue: ``` struct f{ int t; }; const f &g = {1}; ```