public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/45978] New: bogus "array subscript is above array bounds" warning in extremely simple code with no loops
@ 2010-10-12  7:37 miles at gnu dot org
  2010-10-12  9:44 ` [Bug tree-optimization/45978] [4.6 Regression] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: miles at gnu dot org @ 2010-10-12  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: bogus "array subscript is above array bounds" warning
                    in extremely simple code with no loops
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: miles@gnu.org


Created attachment 22021
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22021
C++ source file illustrating bug

[I don't know if the "component:" field is correct, but there doesn't seem to
be a "I don't know" option]

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

However the attached C++ source file ("tt.cc") seems to be almost trivial; it
contains no loops at all, and all array references use a constant (and valid)
index, but it nonetheless elicits an "array subscript is above array bounds"
warning from the compiler.  As far as I can figure, the warning is bogus.

Compilation looks like:

   $ 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]

Version info:

   $ g++-snapshot --version
   g++ (Debian 20101009-1) 4.6.0 20101009 (experimental) [trunk revision
165234]
   Copyright (C) 2010 Free Software Foundation, Inc.
   This is free software; see the source for copying conditions.  There is NO
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

"g++-snapshot" just invokes g++ from Debian's gcc-snapshot package, which is a
somewhat recent trunk snapshot.

["tt.cc" 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


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

end of thread, other threads:[~2013-04-12 16:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-12  7:37 [Bug middle-end/45978] New: bogus "array subscript is above array bounds" warning in extremely simple code with no loops miles at gnu dot org
2010-10-12  9:44 ` [Bug tree-optimization/45978] [4.6 Regression] " rguenth at gcc dot gnu.org
2010-11-15 12:05 ` rguenth at gcc dot gnu.org
2011-02-08 13:39 ` rguenth at gcc dot gnu.org
2011-03-25 20:10 ` [Bug tree-optimization/45978] [4.6/4.7 " jakub at gcc dot gnu.org
2011-05-20  5:17 ` miles at gnu dot org
2011-05-20  8:46 ` [Bug tree-optimization/45978] [4.6 " rguenth at gcc dot gnu.org
2011-06-27 15:56 ` jakub at gcc dot gnu.org
2011-08-19 22:58 ` torsten at debian dot org
2011-10-26 17:57 ` jakub at gcc dot gnu.org
2012-03-01 15:02 ` jakub at gcc dot gnu.org
2012-07-16  6:48 ` Petr.Salinger at seznam dot cz
2013-04-12 16:18 ` jakub 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).