From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8300E385503C; Sat, 21 Aug 2021 11:35:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8300E385503C From: "d-ef at yandex dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102006] New: A false warning "Array subscript -N is outside array bounds warning" Date: Sat, 21 Aug 2021 11:35:41 +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: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: d-ef at yandex dot ru 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: Sat, 21 Aug 2021 11:35:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102006 Bug ID: 102006 Summary: A false warning "Array subscript -N is outside array bounds warning" Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: d-ef at yandex dot ru Target Milestone: --- I am not sure if referencing an entire Git repository is allowed here, but probably it is an easier way to reproduce the bug: git clone https://github.com/dmitriano/Awl --branch gcc-warn mkdir -p build/awl cd build/awl cmake ../../Awl/ -DCMAKE_BUILD_TYPE=3DRelease make Tests/ListTest.cpp.o Compiler output: /home/def/Awl/Tests/ListTest.cpp: In function =E2=80=98void List_TestFunc(c= onst awl::testing::TestContext&)=E2=80=99: /home/def/Awl/Tests/ListTest.cpp:118:70: warning: array subscript 0 is outs= ide array bounds of =E2=80=98{anonymous}::ListHolder [1]=E2=80= =99 [-Warray-bounds] 118 | for (typename ELEMENT_LIST::iterator i =3D list.begin()= ; i !=3D list.end(); ++i) |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~^~~~~~~~~~~~~ /home/def/Awl/Tests/ListTest.cpp:138:33: note: while referencing =E2=80=98h= older=E2=80=99 138 | ListHolder holder(context); | ^~~~~~ If you comment line 114 in Tests/ListTest.cpp the warning disappears that probably is a bit strange, because this line does not relate to the code th= at produces the warning. My OS: Ubuntu 18.04 My compiler: g++ (Ubuntu 11.1.0-1ubuntu1~18.04.1) 11.1.0 for more information on how to build Awl on Ubuntu 18 see https://developernote.com/2021/08/compiling-awl-on-ubuntu-18-with-gcc-11/=