From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 93FE13858CDB; Wed, 21 Sep 2022 17:51:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93FE13858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663782672; bh=yF86AUXEf3bt9ybb0uI8c8KcshXTw2f1vB3N0DHY9lo=; h=From:To:Subject:Date:From; b=s5Lx5kxz+pCqAs6u0C1/3VJM6OKMoM0UT9E1BHe/rUhqlz+G32UJPoqbFf8ue80u/ sDiWKEzJyuUDEdydtbl44XdD5WkWQAqEGDfvJJ+OFrBV/QXpeVsmEx1Y96igPTrXCe 7fihZWc66TuyXNYVAwG8ew4O+E1XhRYn/FtQZHqQ= From: "rogerio.souza at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107004] New: GCC12 warning in OOB access: array subscript is partly outside array bounds Date: Wed, 21 Sep 2022 17:51:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: TREE X-Bugzilla-Severity: normal X-Bugzilla-Who: rogerio.souza 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_file_loc bug_status keywords 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=3D107004 Bug ID: 107004 Summary: GCC12 warning in OOB access: array subscript is partly outside array bounds Product: gcc Version: 12.2.0 URL: https://godbolt.org/z/aoYh66EYb Status: UNCONFIRMED Keywords: TREE Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rogerio.souza at gmail dot com Target Milestone: --- The code below triggers the warning: /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_construct.h:1= 19:7: warning: array subscript 'int*[0]' is partly outside array bounds of 'unsig= ned char [8]' [-Warray-bounds] 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Source code: #include #include void foo(std::vector& v) { assert(v.size() >=3D 1); v.resize(1); } Build command line: g++ -std=3Dc++20 -Wall -Wextra -pedantic -O3 Using -O2 prevents the warning, also if we use "-Wno-array-bounds". This is= sue is not reproducible on GCC 11.3 or older. Would this issue be a duplicate from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105348? The issue could be reproduced on Compiler Explorer: https://godbolt.org/z/aoYh66EYb Regards, Rogerio=