public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63213] New: -Warray-bounds false positive with -O3
@ 2014-09-09  9:58 oliverst at online dot de
  2014-09-09  9:58 ` [Bug c/63213] " oliverst at online dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: oliverst at online dot de @ 2014-09-09  9:58 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/63213] -Warray-bounds false positive with -O3
  2014-09-09  9:58 [Bug c/63213] New: -Warray-bounds false positive with -O3 oliverst at online dot de
@ 2014-09-09  9:58 ` oliverst at online dot de
  2014-09-09 10:04 ` [Bug middle-end/63213] " mpolacek at gcc dot gnu.org
  2021-08-08  3:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: oliverst at online dot de @ 2014-09-09  9:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Oliver Stoeneberg <oliverst at online dot de> ---
Created attachment 33463
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33463&action=edit
preprocessed source


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/63213] -Warray-bounds false positive with -O3
  2014-09-09  9:58 [Bug c/63213] New: -Warray-bounds false positive with -O3 oliverst at online dot de
  2014-09-09  9:58 ` [Bug c/63213] " oliverst at online dot de
@ 2014-09-09 10:04 ` mpolacek at gcc dot gnu.org
  2021-08-08  3:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-09-09 10:04 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
          Component|c                           |middle-end

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm pretty sure this is a dupe, we have many -Warray-bounds bugs.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/63213] -Warray-bounds false positive with -O3
  2014-09-09  9:58 [Bug c/63213] New: -Warray-bounds false positive with -O3 oliverst at online dot de
  2014-09-09  9:58 ` [Bug c/63213] " oliverst at online dot de
  2014-09-09 10:04 ` [Bug middle-end/63213] " mpolacek at gcc dot gnu.org
@ 2021-08-08  3:40 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  3:40 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |8.0
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This was just execusive unrolling of the two loops:

                        while(p[ps1-1].y == cury)
                                ps1--;
                        while(p[ps2+1].y == cury)
                                ps2++;
That was fixed in GCC 8.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-08  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09  9:58 [Bug c/63213] New: -Warray-bounds false positive with -O3 oliverst at online dot de
2014-09-09  9:58 ` [Bug c/63213] " oliverst at online dot de
2014-09-09 10:04 ` [Bug middle-end/63213] " mpolacek at gcc dot gnu.org
2021-08-08  3:40 ` pinskia at gcc dot gnu.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).