From: Steve Ellcey <sellcey@imgtec.com>
To: Richard Biener <rguenther@suse.de>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] -Warray-bounds TLC
Date: Fri, 17 Apr 2015 18:01:00 -0000 [thread overview]
Message-ID: <1429293702.30498.239.camel@ubuntu-sellcey> (raw)
In-Reply-To: <alpine.LSU.2.11.1504161354290.6786@zhemvz.fhfr.qr>
On Thu, 2015-04-16 at 13:55 +0200, Richard Biener wrote:
> The following applies the patch produced earlier this year, applying
> TLC to array bound warnings and catching a few more cases.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
>
> Richard.
>
> 2015-04-16 Richard Biener <rguenther@suse.de>
>
> PR tree-optimization/64277
> * tree-vrp.c (check_array_ref): Fix anti-range handling,
> simplify upper bound handling.
> (search_for_addr_array): Simplify.
> (check_array_bounds): Handle ADDR_EXPRs here.
> (check_all_array_refs): Simplify.
This caused an interesting build failure of glibc when using the latest
GCC. Here is a cut down case from elf/dl-open.c:
extern void foo(void);
struct s { int n; } v[1];
int bar (int i)
{
if ((i != 0 && i != -1 && i != -2) && (v[i].n == 0))
foo ();
return 0;
}
int baz (int i)
{
if ((i != 0 && i != -2) && (v[i].n == 0))
foo ();
return 0;
}
When compiled with -O2 -Wall -Werror, I now get an error about v[i]
being out-of-bounds in bar. But I do not get this error in baz (where
we don't check for -1. In reality, in glibc, we know that i can only be
0, -1, or -2. GCC of course doesn't know that. Does this error/warning
seem right? The difference in behavior between bar and baz seems odd.
Steve Ellcey
sellcey@imgtec.com
next prev parent reply other threads:[~2015-04-17 18:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 11:55 Richard Biener
2015-04-17 18:01 ` Steve Ellcey [this message]
2015-04-17 18:54 ` Richard Biener
2015-04-17 19:08 ` Marc Glisse
2015-04-17 19:53 ` Steve Ellcey
2015-04-17 20:52 ` Steve Ellcey
2015-04-17 21:21 ` Mike Stump
2015-04-17 22:15 ` Marc Glisse
2015-04-17 22:29 ` Steve Ellcey
2015-04-20 8:05 ` Richard Biener
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=1429293702.30498.239.camel@ubuntu-sellcey \
--to=sellcey@imgtec.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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: link
Be 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).