This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/56273] New: [4.8 regression] Bogus -Warray-bounds warning


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]