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

            Bug ID: 63213
           Summary: -Warray-bounds false positive with -O3
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oliverst at online dot de

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

The attached code generates the following warnings:

gcc -Wall -O3 -Wno-uninitialized -c model1.c
model1.c: In function 'fill_quad':
model1.c:94:11: warning: array subscript is above array bounds [-Warray-bounds]
    while(p[ps2+1].y == cury)
           ^
model1.c:114:11: warning: array subscript is above array bounds
[-Warray-bounds]
    while(p[ps2+1].y == cury)
           ^
model1.c:114:11: warning: array subscript is above array bounds
[-Warray-bounds]
model1.c:92:11: warning: array subscript is below array bounds [-Warray-bounds]
    while(p[ps1-1].y == cury)
           ^
model1.c:105:11: warning: array subscript is below array bounds
[-Warray-bounds]
    while(p[ps1-1].y == cury)
           ^
model1.c:105:11: warning: array subscript is below array bounds
[-Warray-bounds]

The code is quite messy and reducing it created some uninitialized warnings,
that didn't exist in the original code, but the array bounds ones stayed the
same. It was about ten times the size of this before I reduced it and I
couldn't reduce it anymore since removing any line reduces the amount of
warnings.

Apparently this false positive started with GCC 4.8.1 on some Linux
distribution (I assume it was some Fedora version), but I didn't have access to
a toolchain, that was causing it until now with the MinGW 4.9.1 release.

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/mingw64-w64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.1/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64
--with-sysroot=/c/mingw491/x86_64-491-win32-seh-rt_v3-rev0/mingw64
--with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared
--enable-static --disable-multilib
--enable-languages=ada,c,c++,fortran,objc,obj-c++,lto
--enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp
--enable-libatomic --enable-lto --enable-graphite --enable-checking=release
--enable-fully-dynamic-string --enable-version-specific-runtime-libs
--disable-isl-version-check --disable-cloog-version-check
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona
--with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/c/mingw491/prerequisites/x86_64-w64-mingw32-static
--with-mpfr=/c/mingw491/prerequisites/x86_64-w64-mingw32-static
--with-mpc=/c/mingw491/prerequisites/x86_64-w64-mingw32-static
--with-isl=/c/mingw491/prerequisites/x86_64-w64-mingw32-static
--with-cloog=/c/mingw491/prerequisites/x86_64-w64-mingw32-static
--enable-cloog-backend=isl --with-pkgversion='x86_64-win32-seh-rev0, Built by
MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64
CFLAGS='-O2 -pipe
-I/c/mingw491/x86_64-491-win32-seh-rt_v3-rev0/mingw64/opt/include
-I/c/mingw491/prerequisites/x86_64-zlib-static/include
-I/c/mingw491/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2
-pipe -I/c/mingw491/x86_64-491-win32-seh-rt_v3-rev0/mingw64/opt/include
-I/c/mingw491/prerequisites/x86_64-zlib-static/include
-I/c/mingw491/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=
LDFLAGS='-pipe -L/c/mingw491/x86_64-491-win32-seh-rt_v3-rev0/mingw64/opt/lib
-L/c/mingw491/prerequisites/x86_64-zlib-static/lib
-L/c/mingw491/prerequisites/x86_64-w64-mingw32-static/lib'
Thread model: win32
gcc version 4.9.1 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)

Reply via email to