[committed] libstdc++: Use std::_Destroy in std::stacktrace

Message ID 20241128184719.934802-1-jwakely@redhat.com
State Committed
Commit 1e2b03e4d66d894c2e42d209502b6957b2dabbf9
Headers
Series [committed] libstdc++: Use std::_Destroy in std::stacktrace |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Jonathan Wakely Nov. 28, 2024, 6:47 p.m. UTC
  This benefits from the optimizations in std::_Destroy which avoid doing
any work when using std::allocator.

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::_M_impl::_M_resize):
	Use std::_Destroy to destroy removed elements.
---

Tested x86_64-linux. Pushed to trunk.

 libstdc++-v3/include/std/stacktrace | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Patch

diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index 2c0f6ba10a9..f94a424e4cf 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -601,8 +601,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	void
 	_M_resize(size_type __n, allocator_type& __alloc) noexcept
 	{
-	  for (size_type __i = __n; __i < _M_size; ++__i)
-	    _AllocTraits::destroy(__alloc, &_M_frames[__i]);
+	  std::_Destroy(_M_frames + __n, _M_frames + _M_size, __alloc);
 	  _M_size = __n;
 	}