From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3BC53893644; Mon, 4 Jan 2021 21:34:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3BC53893644 From: "arnaud02 at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/98518] New: std::array not bound checked with _GLIBCXX_ASSERTIONS Date: Mon, 04 Jan 2021 21:34:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arnaud02 at users dot sourceforge.net 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2021 21:34:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98518 Bug ID: 98518 Summary: std::array not bound checked with _GLIBCXX_ASSERTIONS Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: arnaud02 at users dot sourceforge.net Target Milestone: --- operator[] of std::array is not bound checked when specifying _GLIBCXX_ASSERTIONS. Considering: #define _GLIBCXX_ASSERTIONS 1 #include #include int f(int i) { std::array x =3D {1, 4}; return x[i]; // bounds are not checked=20=20 } int main() { volatile int i =3D 2; printf("f=3D%d\n", f(i)); } the array bound violation is not detected. By constrast, replacing std::arr= ay by std::vector results in the expected assertion violation.=