public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds
@ 2013-12-03 15:50 dnovillo at gcc dot gnu.org
  2013-12-03 18:16 ` [Bug tree-optimization/59377] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2013-12-03 15:50 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/59377] VRP produces bogus warning with -Warray-bounds
  2013-12-03 15:50 [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds dnovillo at gcc dot gnu.org
@ 2013-12-03 18:16 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-12-03 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-12-03
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is an invalid testcase.  GCC does not know what this strlen/memcmp
does.  If we add extern "C" around strlen and memcmp, GCC does not warn.

I think you over reduced the original testcase.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/59377] VRP produces bogus warning with -Warray-bounds
  2013-12-03 15:50 [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds dnovillo at gcc dot gnu.org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-12-03 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I think this is an invalid testcase.  GCC does not know what this
> strlen/memcmp does.  If we add extern "C" around strlen and memcmp, GCC does
> not warn.

Does not warn as GCC is able to optimize away the strlen (and even the memcmp
too).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/59377] VRP produces bogus warning with -Warray-bounds
  2013-12-03 15:50 [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds dnovillo at gcc dot gnu.org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-18 19:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The testcase provided in comment #0 is correctly warning about array bounds as
I had explained.  The testcase is reduced way too much from the original code
and there is no feedback in getting the original testcase in over 7 years so
just closing as invalid.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-18 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-03 15:50 [Bug tree-optimization/59377] New: VRP produces bogus warning with -Warray-bounds dnovillo at gcc dot gnu.org
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

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).