public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/56273] New: [4.8 regression] Bogus -Warray-bounds warning
@ 2013-02-10  7:05 daniel at constexpr dot org
  2013-02-10  7:07 ` [Bug other/56273] " daniel at constexpr dot org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: daniel at constexpr dot org @ 2013-02-10  7:05 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273

             Bug #: 56273
           Summary: [4.8 regression] Bogus -Warray-bounds warning
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel@constexpr.org


The following C++ code cause current gcc master to emit an incorrect array
bounds warning:

$ cat test.cpp 

struct type {
  bool a, b;
  bool get_b() { return b; }
};

type stuff[9u];

void bar();

void foo() {

  for(unsigned i = 0u; i < 9u; i++) {

    if(!stuff[i].a) {
      continue;
    }

    bar();

    for(unsigned j = i + 1u; j < 9u; j++) {
      if(stuff[j].a && stuff[j].get_b()) {
        return;
      }
    }

  }
}

$ g++-4.8.0-pre9999 -Warray-bounds -O3 -c test.cpp
test.cpp: In function ‘void foo()’:
test.cpp:22:17: warning: array subscript is above array bounds [-Warray-bounds]
       if(stuff[j].a && stuff[j].get_b()) {
                 ^

I appreciate static analyzers as much as everyone, but having false positives
in the normal warnings (especially ones enabled at -Wall) can be annoying.

GCC was build from git master just now:

$ g++-4.8.0-pre9999 -v
Using built-in specs.                                                           
COLLECT_GCC=g++-4.8.0-pre9999
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.8.0_pre9999/work/gcc-4.8.0-9999/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0-pre9999
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0-pre9999/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --enable-multilib
--with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0-pre9999/python
--enable-checking=release --disable-libgcj --enable-libstdcxx-time
--enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.0_pre9999'
Thread model: posix
gcc version 4.8.0-pre9999 20130210 (experimental) commit
bc85f3af1b43674782c9b5bb2240117f293b5530 (Gentoo 4.8.0_pre9999)


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

end of thread, other threads:[~2015-02-24 12:50 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-10  7:05 [Bug other/56273] New: [4.8 regression] Bogus -Warray-bounds warning daniel at constexpr dot org
2013-02-10  7:07 ` [Bug other/56273] " daniel at constexpr dot org
2013-02-10  7:35 ` [Bug tree-optimization/56273] " pinskia at gcc dot gnu.org
2013-02-10 12:18 ` rguenth at gcc dot gnu.org
2013-02-11  9:33 ` rguenth at gcc dot gnu.org
2013-02-11 10:52 ` rguenth at gcc dot gnu.org
2013-02-11 13:33 ` rguenth at gcc dot gnu.org
2013-02-11 13:34 ` rguenth at gcc dot gnu.org
2013-02-11 15:09 ` rguenth at gcc dot gnu.org
2013-02-12 16:24 ` vincenzo.innocente at cern dot ch
2013-02-12 23:50 ` pinskia at gcc dot gnu.org
2013-02-21 10:53 ` rguenth at gcc dot gnu.org
2013-02-21 10:54 ` rguenth at gcc dot gnu.org
2013-03-08 15:33 ` rguenth at gcc dot gnu.org
2013-03-22 14:48 ` [Bug tree-optimization/56273] [4.8/4.9 " jakub at gcc dot gnu.org
2013-05-31 10:58 ` jakub at gcc dot gnu.org
2013-10-16  9:48 ` jakub at gcc dot gnu.org
2014-01-07  6:54 ` law at redhat dot com
2014-05-22  9:02 ` [Bug tree-optimization/56273] [4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:26 ` [Bug tree-optimization/56273] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-01-27  9:50 ` [Bug tree-optimization/56273] [4.8/4.9 " rguenth at gcc dot gnu.org
2015-01-27  9:50 ` rguenth at gcc dot gnu.org
2015-01-27 11:03 ` rguenth at gcc dot gnu.org
2015-02-19 14:14 ` rguenth at gcc dot gnu.org
2015-02-24 13:05 ` [Bug tree-optimization/56273] [4.8 " rguenth at gcc dot gnu.org
2015-02-24 13:19 ` rguenth 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).