From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 80441385840D; Tue, 23 Apr 2024 12:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80441385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713876113; bh=NpTyAzwQFkG/a++TxE6toFzsZ4N9TFIUtKr2PtMbRQs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ip2hZnB0ejpY1RIt4UoCnXQeSoXoNKQbGpz5ItTJRq0dJNNXJyV0PIrayM99R1v2A U5lcOpdxg3VaM9ApWAkQsjsVEZq52Ex3Yx6Gwhu7zrDtgZnJ+b3k6G8EDf4SRNeYvN UJfsUvSFtmcqteMCdZDYOM6jjff/Qz92YIP8lDGQ= 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:41:53 +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 #9 from Jan Hubicka --- Your patch gives me error compiling testcase jh@ryzen3:/tmp> ~/trunk-install/bin/g++ -O3 ~/t.C=20 In file included from /home/jh/trunk-install/include/c++/14.0.1/vector:65, from /home/jh/t.C:1: /home/jh/trunk-install/include/c++/14.0.1/bits/stl_uninitialized.h: In instantiation of =E2=80=98_ForwardIterator std::__relocate_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator =3D con= st pair*; _ForwardIterator =3D pair*; _Allocator =3D allocator >; _Traits =3D allocator_traits > >= ]=E2=80=99: /home/jh/trunk-install/include/c++/14.0.1/bits/stl_uninitialized.h:1127:31:= =20=20 required from =E2=80=98_Tp* std::__relocate_a(_Tp*, _Tp*, _Tp*, allocator<_= T2>&) [with _Tp =3D pair; _Up =3D pair]=E2=80=99 1127 | return std::__relocate_a(__cfirst, __clast, __result, __alloc= ); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jh/trunk-install/include/c++/14.0.1/bits/stl_vector.h:509:26: requi= red from =E2=80=98static std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_S_relocate(pointer, pointer, pointer, _Tp_alloc_type&) [with _Tp = =3D std::pair; _Alloc =3D std::allocator >; pointer =3D std::pair*; _Tp_alloc_type =3D std::vector >::_Tp_alloc_type]=E2=80= =99 509 | return std::__relocate_a(__first, __last, __result, __alloc= ); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jh/trunk-install/include/c++/14.0.1/bits/vector.tcc:647:32: required from =E2=80=98void std::vector<_Tp, _Alloc>::_M_realloc_append(_Args&& ...)= [with _Args =3D {const std::pair&}; _Tp =3D std::pair; _Alloc =3D std::allocator >]=E2=80=99 647 | __new_finish =3D _S_relocate(__old_start, __old_finish, | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 648 | __new_start, _M_get_Tp_allocator()); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jh/trunk-install/include/c++/14.0.1/bits/stl_vector.h:1294:21: requ= ired from =E2=80=98void std::vector<_Tp, _Alloc>::push_back(const value_type&) [= with _Tp =3D std::pair; _Alloc =3D std::allocator >; value_type =3D std::pair]=E2=80=99 1294 | _M_realloc_append(__x); | ~~~~~~~~~~~~~~~~~^~~~~ /home/jh/t.C:8:25: required from here 8 | stack.push_back (pair); | ~~~~~~~~~~~~~~~~^~~~~~ /home/jh/trunk-install/include/c++/14.0.1/bits/stl_uninitialized.h:1084:56: error: use of deleted function =E2=80=98const _Tp* std::addressof(const _Tp= &&) [with _Tp =3D pair]=E2=80=99 1084 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 std::addressof(std::move(*__first)))) |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /home/jh/trunk-install/include/c++/14.0.1/bits/stl_pair.h:61, from /home/jh/trunk-install/include/c++/14.0.1/bits/stl_algobase.h:64, from /home/jh/trunk-install/include/c++/14.0.1/vector:62: /home/jh/trunk-install/include/c++/14.0.1/bits/move.h:168:16: note: declared here 168 | const _Tp* addressof(const _Tp&&) =3D delete; | ^~~~~~~~~ /home/jh/trunk-install/include/c++/14.0.1/bits/stl_uninitialized.h:1084:56: note: use =E2=80=98-fdiagnostics-all-candidates=E2=80=99 to display conside= red candidates 1084 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 std::addressof(std::move(*__first)))) |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ It is easy to check if conversion happens - just compile it and see if ther= e is memcpy or memmove in the optimized dump file (or final assembly)=