public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-95353-4-h1NRjCQKrJ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-95353-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |88443 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning is due to a limitation of the compute_objsize() function. A small "supported" test case (one that doesn't depend on a trailing array of non-zero 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 enough 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=/dev/stdout z.c struct S { char n, a[0]; }; void f (struct S *p) { char *q = p->a; q[1] = 1; // no warning } void g (struct S *p, int i) { char *q = p->a + i; q[1] = 1; // spurious -Wstringop-overflow } ;; Function f (f, funcdef_no=0, decl_uid=1933, cgraph_uid=1, symbol_order=0) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } f (struct S * p) { <bb 2> [local count: 1073741824]: MEM[(char *)p_1(D) + 2B] = 1; return; } ;; Function g (g, funcdef_no=1, decl_uid=1938, cgraph_uid=2, symbol_order=1) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } z.c: In function ‘g’: z.c:15:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 15 | q[1] = 1; // spurious -Wstringop-overflow | ~~~~~^~~ g (struct S * p, int i) { char * q; char[0:] * _1; sizetype _2; <bb 2> [local count: 1073741824]: _1 = &p_3(D)->a; <<< doesn't consider that a is a trailing array _2 = (sizetype) i_4(D); q_5 = _1 + _2; MEM[(char *)q_5 + 1B] = 1; <<< warning here return; } Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443 [Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
next prev parent reply other threads:[~2020-05-27 15:15 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-27 2:03 [Bug middle-end/95353] New: " hjl.tools at gmail dot com 2020-05-27 2:05 ` [Bug middle-end/95353] " hjl.tools at gmail dot com 2020-05-27 2:21 ` pinskia at gcc dot gnu.org 2020-05-27 3:15 ` hjl.tools at gmail dot com 2020-05-27 4:58 ` hjl.tools at gmail dot com 2020-05-27 6:42 ` glisse at gcc dot gnu.org 2020-05-27 8:07 ` [Bug tree-optimization/95353] " rguenth at gcc dot gnu.org 2020-05-27 15:15 ` msebor at gcc dot gnu.org [this message] 2020-05-28 4:41 ` amodra at gmail dot com 2020-05-28 15:21 ` msebor at gcc dot gnu.org 2020-05-28 20:10 ` [Bug tree-optimization/95353] [10/11 Regression] spurious -Wstringop-overflow writing to a trailing array plus offset msebor at gcc dot gnu.org 2020-06-03 0:13 ` msebor at gcc dot gnu.org 2020-06-03 16:10 ` msebor at gcc dot gnu.org 2020-06-04 16:18 ` msebor at gcc dot gnu.org 2020-06-10 18:02 ` cvs-commit at gcc dot gnu.org 2020-06-10 18:03 ` [Bug tree-optimization/95353] [10 " msebor at gcc dot gnu.org 2020-06-13 17:32 ` cvs-commit at gcc dot gnu.org 2020-07-23 6:51 ` rguenth at gcc dot gnu.org 2020-08-03 14:41 ` msebor at gcc dot gnu.org 2021-01-06 16:37 ` msebor at gcc dot gnu.org 2021-01-21 22:51 ` msebor at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-95353-4-h1NRjCQKrJ@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).