From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C39DF385B1AC; Tue, 29 Nov 2022 12:26:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39DF385B1AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669724783; bh=UYp+5YVJeX+9SQ7H0EYqy5nWLH7em/JczfBKU5upqsI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SFu0wyTxT2g6/ATDcHy+eOKV4nNvOvMrmBH+s1bij4gZVriwnEkjRxIAuzFEGCZcP DMRjLFp3s4XWAhuxet+41EXbfb0nRQm3Dkr54Pl+mhckWdjNfvCAd5+XgDj2CMSY+8 ScnUx4sGWhRcGGKxH7X5Dgzc2VZjPM9uqmBClXhI= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107852] [12/13 Regression] Spurious warnings stringop-overflow and array-bounds copying data as bytes into vector Date: Tue, 29 Nov 2022 12:26:23 +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: 12.2.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D107852 --- Comment #7 from Richard Biener --- Ontop of the patch I am testing the following fixes the diagnostics: diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 33faabf2eae..aab87b94882 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -784,13 +784,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const size_type __len =3D _M_check_len(__n, "vector::_M_range_insert"); + pointer __tem =3D this->_M_impl._M_start; + pointer __tem2 =3D this->_M_impl._M_finish; pointer __new_start(this->_M_allocate(__len)); pointer __new_finish(__new_start); __try { __new_finish =3D std::__uninitialized_move_if_noexcept_a - (this->_M_impl._M_start, __position.base(), + (__tem, __position.base(), __new_start, _M_get_Tp_allocator()); __new_finish =3D std::__uninitialized_copy_a(__first, __last, @@ -798,7 +800,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_get_Tp_allocator()); __new_finish =3D std::__uninitialized_move_if_noexcept_a - (__position.base(), this->_M_impl._M_finish, + (__position.base(), __tem2, __new_finish, _M_get_Tp_allocator()); } __catch(...)=