public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/61037] New: array-bounds false positive
@ 2014-05-02 18:47 sss@li-snyder.org
  0 siblings, 0 replies; only message in thread
From: sss@li-snyder.org @ 2014-05-02 18:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61037
           Summary: array-bounds false positive
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sss@li-snyder.org

hi -

I'm using gcc from the 4.9 branch:

GNU C++ (GCC) version 4.9.1 20140502 (prerelease) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.1 20140502 (prerelease), GMP version 5.1.2,
MPFR version 3.1.2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072


When I compile this test case with -O3:

struct S
{
  char m_a[21];
  int  m_b[21];
  void copy(const S& other);
};


void S::copy(const S& other)
{
  for(int i=0; i<21; ++i)
  {
    m_b[i] = other.m_b[i];
    m_a[i] = other.m_a[i];
  }
}


I get array bounds warnings:

$ cc1plus -quiet  x.cc -O3 -Wall  -o x.s
x.cc: In member function ‘void S::copy(const S&)’:
x.cc:14:25: warning: array subscript is above array bounds [-Warray-bounds]
     m_a[i] = other.m_a[i];
                         ^
x.cc:14:10: warning: array subscript is above array bounds [-Warray-bounds]
     m_a[i] = other.m_a[i];
          ^
...

For a total of ten copies of those two messages.

The warnings go away if `21' is changed to `20' in the test; 21 is the smallest
i've found that shows the problem.

thanks,
sss
>From gcc-bugs-return-450404-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri May 02 19:03:53 2014
Return-Path: <gcc-bugs-return-450404-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3297 invoked by alias); 2 May 2014 19:03:53 -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 3264 invoked by uid 48); 2 May 2014 19:03:49 -0000
From: "sven.buijssen at math dot uni-dortmund.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/61014] [4.7/4.8/4.9/4.10 Regression] gdb can't find symbol of derived data type array in nested subroutine
Date: Fri, 02 May 2014 19:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: debug
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: sven.buijssen at math dot uni-dortmund.de
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.7.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61014-4-jDVVZihD1N@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61014-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61014-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: 2014-05/txt/msg00096.txt.bz2
Content-length: 759

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

--- Comment #5 from Sven Buijssen <sven.buijssen at math dot uni-dortmund.de> ---
git bisect along with a suitable script identified this gcc commit as culprit:

commit 599471650d6f0fb42b1c1c7e6b24ca21e65132fa
Author: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sat Nov 27 15:53:23 2010 +0000

    config/
        * bootstrap-lto.mk (BOOT_ADAFLAGS): Delete.
    gcc/
        * tree-nested.c (remap_vla_decls): Fully expand value expressions of
        VLA variables.
    gcc/ada/
        * gnatvsn.adb (Version_String): Change type to C-like array of chars.
        (Gnat_Version_String): Adjust to above change.

Since it got merged, gdb can not query bar(1)%i in subfoo() any more.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-02 18:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-02 18:47 [Bug middle-end/61037] New: array-bounds false positive sss@li-snyder.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).