public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-114821-4-g92jmNyTnu@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114821-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114821 --- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> --- I had wrong noexcept specifier. This version works, but I still need to inline 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 = __result; for (; __first != __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 <typename _Tp, typename _Up> _GLIBCXX20_CONSTEXPR inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::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 = __last - __first; @@ -1147,6 +1150,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::__niter_base(__result), __alloc); } + template <typename _Tp, typename _Up> + _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
next prev parent reply other threads:[~2024-04-23 12:38 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-23 8:14 [Bug libstdc++/114821] New: " hubicka at gcc dot gnu.org 2024-04-23 8:30 ` [Bug libstdc++/114821] " redi at gcc dot gnu.org 2024-04-23 8:52 ` hubicka at gcc dot gnu.org 2024-04-23 10:41 ` redi at gcc dot gnu.org 2024-04-23 10:51 ` redi at gcc dot gnu.org 2024-04-23 11:01 ` redi at gcc dot gnu.org 2024-04-23 12:08 ` hubicka at gcc dot gnu.org 2024-04-23 12:33 ` redi at gcc dot gnu.org 2024-04-23 12:38 ` hubicka at gcc dot gnu.org [this message] 2024-04-23 12:41 ` hubicka at gcc dot gnu.org 2024-04-23 12:42 ` redi at gcc dot gnu.org 2024-04-23 13:11 ` redi at gcc dot gnu.org 2024-04-23 15:53 ` redi at gcc dot gnu.org 2024-04-24 14:23 ` hubicka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-114821-4-g92jmNyTnu@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).