From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5B343858D35; Wed, 29 Jul 2020 21:46:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5B343858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596059208; bh=AdAAjA7nsxmqbKMsQtGfAEM/mVbWwjgdqN4rkuNHS64=; h=From:To:Subject:Date:From; b=Xjejgt9TFjA5OGS+DtaXhxoma8/ooPq+jRDh9RJ7YCf/7m6OtR3Nt9ioGEBkKumj3 IIjsUWM8NbLSGApJAEgHSmtSUDIZAg9b04vPsOAkGuTfCAEvriv74D1ZV62RXDj6dV AtUI49BOoRCijQT1PIIZBuiVx0bOhBU52KBA6MjE= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/96384] New: [11 Regression] bogus -Wstringop-overflow= storing into multidimensional array with index in range Date: Wed, 29 Jul 2020 21:46:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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: Wed, 29 Jul 2020 21:46:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96384 Bug ID: 96384 Summary: [11 Regression] bogus -Wstringop-overflow=3D storing into multidimensional array with index in range Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The following test case triggers a false positive -Wstringop-overflow: $ cat z.c && gcc -O2 -S -Wall -fdump-tree-strlen-all=3D/dev/stdout z.c char a[2][3]; void f (unsigned i) { if (i > ~0U - 1) i =3D ~0U - 1; a[i][0] =3D 0; } ;; Function f (f, funcdef_no=3D0, decl_uid=3D1932, cgraph_uid=3D1, symbol_o= rder=3D1) Pass statistics of "strlen": ---------------- ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } extract_range_from_stmt visiting: # RANGE [0, 4294967294] _2 =3D MIN_EXPR ; Intersecting unsigned int [0, 4294967294] and unsigned int [0, 4294967294] to unsigned int [0, 4294967294] z.c: In function =E2=80=98f=E2=80=99: z.c:7:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 7 | a[i][0] =3D 0; | ~~~~~~~~^~~ z.c:1:6: note: at offset 0 to object =E2=80=98a=E2=80=99 with size 6 declar= ed here 1 | char a[2][3]; | ^ maybe_invalidate called for a[_2][0] =3D 0; maybe_invalidate returns 0 Pass statistics of "strlen": ---------------- f (unsigned intD.9 iD.1931) { unsigned intD.9 i_1(D) =3D iD.1931; unsigned intD.9 _2; ;; basic block 2, loop depth 0, count 1073741824 (estimated locally), may= be hot ;; prev block 0, next block 1, flags: (NEW, REACHABLE, VISITED) ;; pred: ENTRY [always] count:1073741824 (estimated locally) (FALLTHRU,EXECUTABLE) # RANGE [0, 4294967294] _2 =3D MIN_EXPR ; # .MEM_4 =3D VDEF <.MEM_3(D)> aD.1930[_2][0] =3D 0; # VUSE <.MEM_4> return; ;; succ: EXIT [always] count:1073741824 (estimated locally) (EXECUTABLE) }=