From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 976FE3858D33; Mon, 16 Jan 2023 13:14:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 976FE3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673874863; bh=tjFa4++N3Jtcd90gRadKh0GK+MBzkMliAToYCLkHHFA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ph17laDHLFEzONhwmo4VAWAIig94yln6SooaQewIzyHYj+OG1b0ziXNC4+ak4qyQI Ddh87UnhCI91X/TNlAo4idZbsg0yoBcydpwpZ++1cBjD6awpcqbTBzxZrTyMP381Oz GUL83X1tzgAP+U8pGb/df9p9MroVWeG8rSx9fyJg= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106093] [12/13 Regression] False positive -Wstringop-overflow with -O3 when resizing std::vector Date: Mon, 16 Jan 2023 13:14:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 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=3D106093 --- Comment #2 from Jonathan Wakely --- (In reply to Richard Biener from comment #1) > in particular the new allocated storage is processed but the old size is > used?! Yes, that seems correct. We're resizing the vector from N to N+1 (where N happens to be 0). The new = size is greater than the existing capacity, so we allocate N+1 elements, then co= py the existing N elements into the new storage (which uses old_finish - old_start). Afterwards, we would actually construct the new element in the new storage,= but the warning happens while just copying the elements from the old storage to= the new.=