From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D42E03858D38; Mon, 23 Jan 2023 15:28:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D42E03858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674487702; bh=wFsSVsVZ6HUhKbZlArTAbZueCq91m8N0ckURgSZZPUo=; h=From:To:Subject:Date:From; b=ombNvK0tTtLyZnlssLntFdB4N5z7H1/kIvGJMJQRWav7ewEsVuA6rvpvHQy406LFI nsTVm3RoVXrGlb6Z4MlilDzuOzRVFcE7dlkVN2/nAfenZn6ypC6gDOYBY1VD8tn5nb 7Xb069iacjuRjcUAPKwr9Xjpn94CQVWKNLCy2C4Q= From: "steveire at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108499] New: False positive -Warray-bounds Date: Mon, 23 Jan 2023 15:28:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: steveire 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D108499 Bug ID: 108499 Summary: False positive -Warray-bounds Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- ``` #include class MyStruct { public: std::vector const& refAccessor(); std::size_t getSize(); }; void emitsWarning() { MyStruct params; auto unusedThing =3D params.refAccessor(); (void)unusedThing; auto const theSize =3D params.getSize(); std::vector initialVelocities(theSize, 0.0); initialVelocities.back() =3D 6; std::vector initialJoints(theSize, 0.0); initialJoints.back() =3D 5; } ``` -Werror=3Darray-bounds -O2 ``` : In function 'void emitsWarning()': :20:27: error: array subscript -1 is outside array bounds of 'double [1152921504606846975]' [-Werror=3Darray-bounds] 20 | initialVelocities.back() =3D 6; | ~~~~~~~~~~~~~~~~~~~~~~^~ cc1plus: some warnings being treated as errors Compiler returned: 1 ``` https://gcc.godbolt.org/z/sYrK6o54a=