public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dnovillo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds
Date: Tue, 03 Dec 2013 15:50:00 -0000	[thread overview]
Message-ID: <bug-59377-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59377

            Bug ID: 59377
           Summary: VRP produces bogus warning with -Warray-bounds
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dnovillo at gcc dot gnu.org
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu

Using trunk and 4.8.x, this code produces a bogus -Warray-bounds warning:

typedef decltype(sizeof(void*)) size_t;

size_t strlen(const char *);
int memcmp (const void *, const void *, size_t);

struct StringPiece
{
   const char *ptr_;
   size_t size_;
   StringPiece ();
   StringPiece (const char *p1):ptr_ (p1), size_(strlen(p1)) { }
   const char *data () { return ptr_; }
   size_t length() { return size_; }
};


void operator== (StringPiece, StringPiece p2)
{
   const char *a = p2.data (), *b = a;
   if (p2.length() > 8) {
     b += 8;
     memcmp (a, b, 1);
   }
}
void
UtilsSplitQuotedStrings ()
{
   StringPiece c;
   c == "";
}

$ trunk/bld/bin/g++ -std=c++11 -c -Warray-bounds -O2 a.cc
a.cc: In function ‘void UtilsSplitQuotedStrings()’:
a.cc:22:23: warning: array subscript is above array bounds [-Warray-bounds]
      memcmp (a, b, 1);
$                      ^

The warning disappears with -fno-tree-vrp:

$ trunk/bld/bin/g++ -std=c++11 -c -Warray-bounds -O2 a.cc -fno-tree-vrp
$

I've seen some similar looking bug reports, but none seemed related with VRP.
>From gcc-bugs-return-436541-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 03 15:53:54 2013
Return-Path: <gcc-bugs-return-436541-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12210 invoked by alias); 3 Dec 2013 15:53:54 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12178 invoked by uid 48); 3 Dec 2013 15:53:51 -0000
From: "ppluzhnikov at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59377] VRP produces bogus warning with -Warray-bounds
Date: Tue, 03 Dec 2013 15:53:00 -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: 4.8.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ppluzhnikov at google dot com
X-Bugzilla-Status: UNCONFIRMED
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:
Message-ID: <bug-59377-4-814Y7uGDnv@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59377-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59377-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00196.txt.bz2
Content-length: 146

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY377

--- Comment #1 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Google ref: b/7233326


             reply	other threads:[~2013-12-03 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 15:50 dnovillo at gcc dot gnu.org [this message]
2013-12-03 18:16 ` [Bug tree-optimization/59377] " pinskia at gcc dot gnu.org
2013-12-03 18:25 ` pinskia at gcc dot gnu.org
2021-07-18 19:49 ` pinskia 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-59377-4@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: 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).