This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/61037] New: array-bounds false positive


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]