Hi
As back to stage 1is it ok to commit this change ?
François
On 31/03/2025 22:20, François Dumont wrote:
Hi
Following this previous patch
https://gcc.gnu.org/pipermail/libstdc++/2024-August/059418.html I've
completed it for the _Safe_unordered_container_base type and
implemented the rest of the change to store the safe iterator sequence
as a pointer-to-const.
libstdc++: Make debug iterator pointer sequence const [PR116369]
In revision a35dd276cbf6236e08bcf6e56e62c2be41cf6e3c the debug
sequence
have been made mutable to allow attach iterators to const containers.
This change completes this fix by also declaring debug unordered
container
members mutable.
Additionally the debug iterator sequence is now a pointer-to-const
and so
_Safe_sequence_base _M_attach and all other methods are const
qualified.
Symbols export are maintained thanks to __asm directives.
libstdc++-v3/ChangeLog:
PR c++/116369
* include/debug/safe_base.h
(_Safe_iterator_base::_M_sequence): Declare as
pointer-to-const.
(_Safe_iterator_base::_M_attach, _M_attach_single): Take
pointer-to-const
_Safe_sequence_base. Add __asm directive to preserve name
mangling.
(_Safe_sequence_base::_M_detach_all, _M_detach_singular,
_M_revalidate_singular)
(_M_swap, _M_get_mutex, _M_attach, _M_attach_single,
_M_detash, _M_detash_single):
Add const qualifier and __asm directive to preserve name
mangling.
* include/debug/safe_unordered_base.h
(_Safe_local_iterator_base::_M_get_container): Make public
and return
_Safe_unordered_container_base as pointer-to-const.
(_Safe_local_iterator_base::_Safe_local_iterator_base): Take
_Safe_unordered_container_base as pointer-to-const.
(_Safe_unordered_container_base::_M_attach,
_M_attach_single): Take
_Safe_unordered_container_base as pointer-to-const. Add
__asm directive to preserve
name mangling.
(_Safe_unordered_container_base::_M_local_iterators,
_M_const_local_iterators):
Add mutable.
(_Safe_unordered_container_base::_M_detach_all, _M_swap,
_M_attach_local)
(_M_attach_local_single, _M_detach_loca,
_M_detach_local_single): Add const
qualifier and __asm directive to preserve name mangling.
* include/debug/safe_iterator.h
(_Safe_iterator<>::_M_attach, _M_attach_single):
Take _Safe_sequence_base as pointer-to-const.
(_Safe_iterator<>::_M_get_sequence): Add const_cast and
comment about it.
* include/debug/safe_local_iterator.h
(_Safe_local_iterator<>): Replace usages
of _M_sequence member by _M_get_container().
(_Safe_local_iterator<>::_M_attach, _M_attach_single): Take
_Safe_unordered_container_base as pointer-to-const.
(_Safe_local_iterator<>::_M_get_sequence): Rename into...
(_Safe_local_iterator<>::_M_get_ucontainer): ...this. Add
necessary const_cast and
comment to explain it.
* include/debug/safe_sequence.h
(_Safe_sequence<>::_M_invalidate_if, _M_transfer_from_if):
Add const qualifier.
* include/debug/safe_sequence.tcc: Adapt.
* src/c++11/debug.cc: Adapt to const qualification.
* testsuite/util/testsuite_containers.h
(forward_members_unordered::forward_members_unordered): Add check on
local_iterator
conversion to const_local_iterator.
(forward_members::forward_members): Add check on iterator
conversion to
const_iterator.
Also available as a PR
https://forge.sourceware.org/gcc/gcc-TEST/pulls/47
Tested under Linux x64.
Ok to commit ?
François