https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116369

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> 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

Why? It's only ever written to in the constructor and in non-const member
functions.

One of those functions is _M_detach_all() which is called from the destructor,
but that's fine because 'this' is non-const during construction and
destruction. (This makes me wonder how any object with a non-trivial destructor
that calls some non-inline function can ever be placed in rodata, because the
destructor could perform arbitrary writes to data members which aren't
necessarily removed by DSE.)

Reply via email to