From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 31B3C3858C42; Tue, 23 Apr 2024 12:38:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31B3C3858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713875902; bh=rbPUsqVD+zdwXa3u5BgEj2K2Li7UP/OqYIAQCdWW7ls=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GdFlpXfh2Hf865RyeI1HgN/rtHwCBocxWzbcQoyvdjYrqHQHiQOP+dn/6fqggr0Lc Ikre1bxl+kR/REnULvKqg8uYsaAx0d3ymKv1gbVXvl0S4B3UdcalD1MPnT7hQlRQhZ X/OFmEoggkYAY1PzNWXJI834UGwEGHigI71dZhPs= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114821] _M_realloc_append should use memcpy instead of loop to copy data when possible Date: Tue, 23 Apr 2024 12:38:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114821 --- Comment #8 from Jan Hubicka --- I had wrong noexcept specifier. This version works, but I still need to in= line relocate_object_a into the loop diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 7f84da31578..f02d4fb878f 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -1100,8 +1100,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "relocation is only possible for values of the same type"); _ForwardIterator __cur =3D __result; for (; __first !=3D __last; ++__first, (void)++__cur) - std::__relocate_object_a(std::__addressof(*__cur), - std::__addressof(*__first), __alloc); + { + typedef std::allocator_traits<_Allocator> __traits; + __traits::construct(__alloc, std::__addressof(*__cur), std::move(*std::__addressof(*__first))); + __traits::destroy(__alloc, std::__addressof(*std::__addressof(*__first))); + } return __cur; } @@ -1109,8 +1112,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template _GLIBCXX20_CONSTEXPR inline __enable_if_t::value, _Tp*> - __relocate_a_1(_Tp* __first, _Tp* __last, - _Tp* __result, + __relocate_a_1(_Tp* __restrict __first, _Tp* __last, + _Tp* __restrict __result, [[__maybe_unused__]] allocator<_Up>& __alloc) noexcept { ptrdiff_t __count =3D __last - __first; @@ -1147,6 +1150,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::__niter_base(__result), __alloc); } + template + _GLIBCXX20_CONSTEXPR + inline _Tp* + __relocate_a(_Tp* __restrict __first, _Tp* __last, + _Tp* __restrict __result, + allocator<_Up>& __alloc) + noexcept(noexcept(__relocate_a_1(__first, __last, __result, __alloc))) + { + return std::__relocate_a_1(__first, __last, __result, __alloc); + } + /// @endcond #endif // C++11=