public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vincent Lefevre <vincent+gcc@vinc17.org>
To: gcc-help@gcc.gnu.org
Subject: Re: False positive from -Warray-bounds?
Date: Fri, 30 Dec 2011 00:16:00 -0000	[thread overview]
Message-ID: <20111229235727.GU5641@xvii.vinc17.org> (raw)
In-Reply-To: <mcrr4zn3qsn.fsf@dhcp-172-18-216-180.mtv.corp.google.com>

On 2011-12-29 15:24:08 -0800, Ian Lance Taylor wrote:
> I guess it's a matter of perspective.  What that text is intended to say
> is: the compiler can prove that the array access is out of bounds.

... based on an incorrect hypothesis (that the path can be reached).
With an incorrect hypothesis, one can prove anything. So, I don't
think that would be a valid proof.

For instance, compiling the following code with -O2 -Warray-bounds -c
triggers the warning.

unsigned int f(unsigned int value)
{
  unsigned int i = (value & 0xffff);
  return (i == 0xffff ? 0xffffffff : i);
}

static int arr1[10];

void t(unsigned int s)
{
  if (s >> 1 == 0)
    {
      arr1[f(s)] = 0;
      arr1[f(s)] = 0;
    }
}

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

  reply	other threads:[~2011-12-29 23:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29 22:02 Lars Gullik Bjønnes
2011-12-29 22:45 ` Ian Lance Taylor
2011-12-29 23:03   ` Lars Gullik Bjønnes
2011-12-29 23:57     ` Ian Lance Taylor
2011-12-30  0:16       ` Vincent Lefevre [this message]
2011-12-30  0:21         ` Vincent Lefevre
2011-12-30  0:38         ` Ian Lance Taylor
2011-12-30  5:00           ` Vincent Lefevre
2011-12-30  8:29             ` Ian Lance Taylor
2011-12-30 12:08               ` David Brown
2011-12-30 19:44                 ` Vincent Lefevre
2011-12-29 23:24   ` Vincent Lefevre
2011-12-30  0:19     ` Ian Lance Taylor
2011-12-29 23:17 ` Vincent Lefevre

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=20111229235727.GU5641@xvii.vinc17.org \
    --to=vincent+gcc@vinc17.org \
    --cc=gcc-help@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: 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).