From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A7ABB388301D; Tue, 2 Apr 2024 20:20:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7ABB388301D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712089250; bh=R9grMqeHVSiPzuLUqAQFI2bWOVjJTblG1oYDeiw+A18=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aj4vvqXImrjCF9hFTevXw3LAABDw4VhD2uF3PTcYsMRR7l0J9dg0bVc3akYlmrzd0 tVCCSbTLfLlki01O8HKIPKKcXeD7A7/DBoJlKy2XFH9lFAACO0IX51VscUzRrumVAh flktu/IrYpbuzi6/JYbXzm1qN8NS4m5Cyk45hwto= From: "michael.ragazzon at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110498] Spurious warnings stringop-overflow and array-bounds copying data as bytes into vector::reserve Date: Tue, 02 Apr 2024 20:20:49 +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: 13.1.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: michael.ragazzon at gmail dot com 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: cc 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=3D110498 Michael Ragazzon changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |michael.ragazzon at gmail = dot com --- Comment #1 from Michael Ragazzon --- I seem to also have encountered this issue while using `std::vector`. Here is a relatively small reproducer. Compile with: -O3 -std=3Dc++17 -Wall -Werror --- #include #include class Testing { public: Testing(); private: std::vector elements; }; Testing::Testing() { // Warning emitted when set to any number in the range [1,64]. constexpr size_t reserve_size =3D 30; elements.reserve(reserve_size); elements.push_back(0); } int main() { Testing testing; } --- https://godbolt.org/z/eG66sjsPq This issue seems to have started with GCC 13.1, and exists also on current trunk (tested on Compiler Explorer).=