[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#599572: gcc-snapshot: bogus "array subscript is above array bounds" in extremely simple code with no loops



Package: gcc-snapshot
Version: 20100918-1
Severity: normal


There are many bugs in gcc's bugzilla related to bogus array-bounds
warnings, but most of them seem to involve non-trivial loops and other
situations that may need non-trivial analysis by the compiler.

By contrast, the appended code seems to be almost trivial, and
contains no loops at all, but nonetheless elicits an "array subscript
is above array bounds" warning from the compiler:

   g++-snapshot -O3 -S -Wall -Wextra tt.cc
   tt.cc: In function 'Z test()':
   tt.cc:15:21: warning: array subscript is above array bounds [-Warray-bounds]

[This is as minimal as I can get it -- moving, eliminating, or
changing any field in any of the structures seems to silence the
warning.]

Thanks,

-Miles

p.s. I wasn't sure whether it's better to report bugs with
gcc-snapshot to debian or to upstream bugzilla...


---- start of code "tt.c" ----
struct X
{
  X () : x (0), y (0), z (0) { }
  float x, y, z;
};

struct Y
{
  Y () { ar[0] = 0; ar[1] = 0; ar[2] = 0; }
  float ar[3];
};

struct Z
{
  Z () : b (0), d (0) { }
  Y a;
  float b;
  X c;
  float d;
};

Z test () { return Z (); }
---- end of code ----



-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (101, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.35-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-snapshot depends on:
ii  binutils              2.20.51.20100925-1 The GNU assembler, linker and bina
ii  ecj-gcj [libecj-java- 3.5.1-1            standalone version of the Eclipse 
ii  libc6                 2.11.2-6           Embedded GNU C Library: Shared lib
ii  libc6-dev             2.11.2-6           Embedded GNU C Library: Developmen
ii  libc6-dev-i386        2.11.2-6           Embedded GNU C Library: 32-bit dev
ii  libc6-i386            2.11.2-6           Embedded GNU C Library: 32-bit sha
ii  libcloog-ppl0         0.15.9-2           the Chunky Loop Generator (runtime
ii  libecj-java-gcj       3.5.1-1            Eclipse Java compiler (native libr
ii  libelfg0              0.8.13-1           an ELF object file access library
ii  libgmp3c2             2:4.3.2+dfsg-1     Multiprecision arithmetic library
ii  libgmpxx4ldbl         2:4.3.2+dfsg-1     Multiprecision arithmetic library 
ii  libmpc2               0.8.2-1+b1         multiple precision complex floatin
ii  libmpfr4              3.0.0-2            multiple precision floating-point 
ii  libppl-c2             0.10.2-8           Parma Polyhedra Library (C interfa
ii  libppl7               0.10.2-8           Parma Polyhedra Library (runtime l
ii  python                2.6.6-3            interactive high-level object-orie
ii  zlib1g                1:1.2.3.4.dfsg-3   compression library - runtime

gcc-snapshot recommends no packages.

Versions of packages gcc-snapshot suggests:
ii  binutils-gold         2.20.51.20100925-1 The (experimental) GNU gold linker

-- no debconf information



Reply to: