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

            Bug ID: 87072
           Summary: g++6.2.0 false warning: array subscript is above array
                    bounds, with misleading line number
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stiefschmied at alice dot de
  Target Milestone: ---

Created attachment 44578
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44578&action=edit
C++ code fragment to reproduce the false warning

The code attached below gives a false warning:

fit.cxx: In member function ‘void Fit::NewtonStep()’:
fit.cxx:7:53: warning: array subscript is above array bounds [-Warray-bounds]
   inline void AddToPar(unsigned i,double x) { par[i]+=x; }

when compiled with: g++ -Wall -O3 -c

The warning disappears when commenting out line 11, which contains completely
unrelated code. It also disappears when commenting out line 28, where the
inline code from line 7 actually is expanded. The warning is also absent when
compiling with a reduced level of optimisation.

output of g++ -v
=================
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Gcc/gcc620_x86_64_slc6/6.2.0/x86_64-slc6/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-6.2.0/configure
--prefix=/build/pmendez-sftnight/install-620local -with-system-zlib
--disable-multilib --enable-languages=all
Thread model: posix
gcc version 6.2.0 (GCC)

Reply via email to