From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DCFBC396EC7E; Wed, 27 May 2020 15:15:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCFBC396EC7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590592554; bh=p9vnWITgS7Ipmm/cuG3x1Cn7jGe7ZgiKLNz/P6qllnI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XXRHY1kPNBuxPgIoUOjV9sUDbuGRUagTiiJ8qa+VvoeSDBBDW9EVwwlENUvY33lcf CPgibyTDjUNbDwMiO6klrtnEOq1yzyww1ie9b+88T5oZ0U5EQfX7pGy4amMg2ZJ4Fd VjDGnAxSsuqlVPXIzc7UoIcbTjgpB6M5sbeWd5J4= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95353] [10/11 Regression] GCC can't build binutils Date: Wed, 27 May 2020 15:15:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: blocked assigned_to bug_status Message-ID: In-Reply-To: References: 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, 27 May 2020 15:15:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95353 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |88443 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org Status|NEW |ASSIGNED --- Comment #5 from Martin Sebor --- The warning is due to a limitation of the compute_objsize() function. A sm= all "supported" test case (one that doesn't depend on a trailing array of non-z= ero size being treated as a flexible array member) that I think reproduces the Binutils warning is below. In this case the function doesn't work hard eno= ugh to determine that the pointer points to a trailing array member and instead uses the the array's actual size. It needs to be improved or preferably rewritten as discussed in pr94335 comment 7. As suggested, using a flexible array member instead of the one-element (or zero-length) array avoids the warning. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-strlen=3D/dev/stdout z.c struct S { char n, a[0]; }; void f (struct S *p) { char *q =3D p->a; q[1] =3D 1; // no warning } void g (struct S *p, int i) { char *q =3D p->a + i; q[1] =3D 1; // spurious -Wstringop-overflow } ;; Function f (f, funcdef_no=3D0, decl_uid=3D1933, cgraph_uid=3D1, symbol_o= rder=3D0) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } f (struct S * p) { [local count: 1073741824]: MEM[(char *)p_1(D) + 2B] =3D 1; return; } ;; Function g (g, funcdef_no=3D1, decl_uid=3D1938, cgraph_uid=3D2, symbol_o= rder=3D1) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } z.c: In function =E2=80=98g=E2=80=99: z.c:15:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 15 | q[1] =3D 1; // spurious -Wstringop-overflow | ~~~~~^~~ g (struct S * p, int i) { char * q; char[0:] * _1; sizetype _2; [local count: 1073741824]: _1 =3D &p_3(D)->a; <<< doesn't consider that a is a trailing = array _2 =3D (sizetype) i_4(D); q_5 =3D _1 + _2;=20=20=20=20=20=20=20=20=20=20=20=20=20=20 MEM[(char *)q_5 + 1B] =3D 1; <<< warning here return; } Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88443 [Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings=