gcc/libstdc++-v3/testsuite/23_containers/multiset
Jonathan Wakely c2e28df90a libstdc++: Destroy allocators in re-inserted container nodes [PR114401]
The allocator objects in container node handles were not being destroyed
after the node was re-inserted into a container. They are stored in a
union and so need to be explicitly destroyed when the node becomes
empty. The containers were zeroing the node handle's pointer, which
makes it empty, causing the handle's destructor to think there's nothign
to clean up.

Add a new member function to the node handle which destroys the
allocator and zeros the pointer. Change the containers to call that
instead of just changing the pointer manually.

We can also remove the _M_empty member of the union which is not
necessary.

libstdc++-v3/ChangeLog:

	PR libstdc++/114401
	* include/bits/hashtable.h (_Hashtable::_M_reinsert_node): Call
	release() on node handle instead of just zeroing its pointer.
	(_Hashtable::_M_reinsert_node_multi): Likewise.
	(_Hashtable::_M_merge_unique): Likewise.
	(_Hashtable::_M_merge_multi): Likewise.
	* include/bits/node_handle.h (_Node_handle_common::release()):
	New member function.
	(_Node_handle_common::_Optional_alloc::_M_empty): Remove
	unnecessary union member.
	(_Node_handle_common): Declare _Hashtable as a friend.
	* include/bits/stl_tree.h (_Rb_tree::_M_reinsert_node_unique):
	Call release() on node handle instead of just zeroing its
	pointer.
	(_Rb_tree::_M_reinsert_node_equal): Likewise.
	(_Rb_tree::_M_reinsert_node_hint_unique): Likewise.
	(_Rb_tree::_M_reinsert_node_hint_equal): Likewise.
	* testsuite/23_containers/multiset/modifiers/114401.cc: New test.
	* testsuite/23_containers/set/modifiers/114401.cc: New test.
	* testsuite/23_containers/unordered_multiset/modifiers/114401.cc: New test.
	* testsuite/23_containers/unordered_set/modifiers/114401.cc: New test.
2024-03-22 22:39:06 +00:00
..
allocator Update copyright years. 2024-01-03 12:19:35 +01:00
capacity Update copyright years. 2024-01-03 12:19:35 +01:00
cons Update copyright years. 2024-01-03 12:19:35 +01:00
debug Update copyright years. 2024-01-03 12:19:35 +01:00
modifiers libstdc++: Destroy allocators in re-inserted container nodes [PR114401] 2024-03-22 22:39:06 +00:00
operations Update copyright years. 2024-01-03 12:19:35 +01:00
operators Update copyright years. 2024-01-03 12:19:35 +01:00
requirements Update copyright years. 2024-01-03 12:19:35 +01:00
14340.cc Update copyright years. 2024-01-03 12:19:35 +01:00
23781_neg.cc Update copyright years. 2024-01-03 12:19:35 +01:00
48101-2_neg.cc Update copyright years. 2024-01-03 12:19:35 +01:00
48101-3_neg.cc Update copyright years. 2024-01-03 12:19:35 +01:00
48101_neg.cc Update copyright years. 2024-01-03 12:19:35 +01:00
58764.cc Update copyright years. 2024-01-03 12:19:35 +01:00
init-list.cc Update copyright years. 2024-01-03 12:19:35 +01:00
pmr_typedefs.cc Update copyright years. 2024-01-03 12:19:35 +01:00
pmr_typedefs_debug.cc Update copyright years. 2024-01-03 12:19:35 +01:00
range_access.cc Update copyright years. 2024-01-03 12:19:35 +01:00