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

            Bug ID: 66031
           Summary: Spurious array bounds warning
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmattson at vmware dot com
  Target Milestone: ---

Created attachment 35472
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35472&action=edit
Preprocessed source file

As a result of inlining, gcc generates an unreachable out-of-bounds array
access and then complains about it.

% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--program-suffix=-4.8 --enable-linux-futex --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.8.1 20130909 [gcc-4_8-branch revision 202388] (SUSE Linux) 

% gcc -O2 -Wall v.i
v.c: In function ‘main’:
v.c:7:28: warning: array subscript is above array bounds [-Warray-bounds]
    if (n - 1 >= f) return p[n];
                            ^

Reply via email to