public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/43949] New: bogus warning: array subscript is above array bounds
@ 2010-04-30 16:26 joachim dot reichel at gmx dot de
2010-04-30 17:25 ` [Bug other/43949] " rguenth at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: joachim dot reichel at gmx dot de @ 2010-04-30 16:26 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]
$ cat test.cpp
void f();
int c[3];
int result;
struct Vector {
static int get(int i) {
if (i >= 3)
f();
return c[i];
}
};
void g()
{
for (int i = 0; i < 3; ++i) {
const int index = i % 3;
result = Vector::get(index) + Vector::get(index);
}
}
$ g++ -Wall -c test.cpp
[no warnings]
$ g++ -Wall -c -O2 test.cpp
test.cpp: In function void g():
test.cpp:10: error: array subscript is above array bounds
$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.2-9'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--with-arch-32=i486 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 20100108 (prerelease) (Debian 4.4.2-9)
The bogus warning disappears if
- (index) is replaced by (i)
- Vector::get(index) is assigned to result (no addition)
- the if statement is removed (call of f() in all cases)
- get() is a global function
The bogus warning does not appear in gcc 4.2.4 (Debian 4.2.4-6). It appears
also in 4.3.2 (Debian 4.3.2-1.1) and gcc 4.5.0 (GCC).
--
Summary: bogus warning: array subscript is above array bounds
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: joachim dot reichel at gmx dot de
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug other/43949] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
@ 2010-04-30 17:25 ` rguenth at gcc dot gnu dot org
2010-05-01 21:30 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-30 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2010-04-30 17:25 -------
Confirmed. VRP is stupid and does
Visiting statement:
index_4 = i_21 % 3;
Found new range for index_4: VARYING
Yet another missed optimization.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-04-30 17:25:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug other/43949] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
2010-04-30 17:25 ` [Bug other/43949] " rguenth at gcc dot gnu dot org
@ 2010-05-01 21:30 ` rguenth at gcc dot gnu dot org
2010-05-01 21:31 ` [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-01 21:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2010-05-01 21:30 -------
Subject: Bug 43949
Author: rguenth
Date: Sat May 1 21:30:26 2010
New Revision: 158965
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158965
Log:
2010-05-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43949
* tree-vrp.c (ssa_name_nonnegative_p): Return true for unsigned
types.
(extract_range_from_binary_expr): Handle *_MOD_EXPR.
* g++.dg/warn/Warray-bounds-5.C: New testcase.
Added:
trunk/gcc/testsuite/g++.dg/warn/Warray-bounds-5.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vrp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
2010-04-30 17:25 ` [Bug other/43949] " rguenth at gcc dot gnu dot org
2010-05-01 21:30 ` rguenth at gcc dot gnu dot org
@ 2010-05-01 21:31 ` rguenth at gcc dot gnu dot org
2010-05-04 9:54 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-01 21:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-05-01 21:31 -------
Fixed for trunk sofar.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|other |tree-optimization
Keywords| |diagnostic, missed-
| |optimization
Known to work| |4.2.4 4.6.0
Summary|bogus warning: array |[4.3/4.4/4.5 Regression]
|subscript is above array |bogus warning: array
|bounds |subscript is above array
| |bounds
Target Milestone|--- |4.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (2 preceding siblings ...)
2010-05-01 21:31 ` [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
@ 2010-05-04 9:54 ` rguenth at gcc dot gnu dot org
2010-05-14 12:58 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-04 9:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2010-05-04 09:53 -------
Subject: Bug 43949
Author: rguenth
Date: Tue May 4 09:53:28 2010
New Revision: 159020
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159020
Log:
2010-05-04 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43949
* tree-vrp.c (extract_range_from_binary_expr): Only handle
TRUNC_MOD_EXPR.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-vrp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (3 preceding siblings ...)
2010-05-04 9:54 ` rguenth at gcc dot gnu dot org
@ 2010-05-14 12:58 ` rguenth at gcc dot gnu dot org
2010-05-21 9:12 ` joachim dot reichel at gmx dot de
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-14 12:58 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (4 preceding siblings ...)
2010-05-14 12:58 ` rguenth at gcc dot gnu dot org
@ 2010-05-21 9:12 ` joachim dot reichel at gmx dot de
2010-05-21 9:15 ` rguenther at suse dot de
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: joachim dot reichel at gmx dot de @ 2010-05-21 9:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from joachim dot reichel at gmx dot de 2010-05-21 09:12 -------
Will this problem get fixed on the 4.5 branch too?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (5 preceding siblings ...)
2010-05-21 9:12 ` joachim dot reichel at gmx dot de
@ 2010-05-21 9:15 ` rguenther at suse dot de
2010-05-21 11:17 ` rguenth at gcc dot gnu dot org
2010-05-22 18:36 ` [Bug tree-optimization/43949] [4.3/4.4 " rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 11+ messages in thread
From: rguenther at suse dot de @ 2010-05-21 9:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenther at suse dot de 2010-05-21 09:15 -------
Subject: Re: [4.3/4.4/4.5 Regression] bogus
warning: array subscript is above array bounds
On Fri, 21 May 2010, joachim dot reichel at gmx dot de wrote:
> ------- Comment #5 from joachim dot reichel at gmx dot de 2010-05-21 09:12 -------
> Will this problem get fixed on the 4.5 branch too?
Yes.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (6 preceding siblings ...)
2010-05-21 9:15 ` rguenther at suse dot de
@ 2010-05-21 11:17 ` rguenth at gcc dot gnu dot org
2010-05-22 18:36 ` [Bug tree-optimization/43949] [4.3/4.4 " rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-21 11:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2010-05-21 11:17 -------
Subject: Bug 43949
Author: rguenth
Date: Fri May 21 11:16:46 2010
New Revision: 159656
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159656
Log:
2010-05-21 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43949
* tree-vrp.c (ssa_name_nonnegative_p): Return true for unsigend
types.
(extract_range_from_binary_expr): Handle TRUNC_MOD_EXPR.
* g++.dg/warn/Warray-bounds-5.C: New testcase.
Added:
branches/gcc-4_5-branch/gcc/testsuite/g++.dg/warn/Warray-bounds-5.C
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
branches/gcc-4_5-branch/gcc/tree-vrp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4 Regression] bogus warning: array subscript is above array bounds
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
` (7 preceding siblings ...)
2010-05-21 11:17 ` rguenth at gcc dot gnu dot org
@ 2010-05-22 18:36 ` rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2010-05-22 18:14 -------
GCC 4.3.5 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.5 |4.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/43949] [4.3/4.4 Regression] bogus warning: array subscript is above array bounds
[not found] <bug-43949-4@http.gcc.gnu.org/bugzilla/>
@ 2011-06-27 13:55 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-27 13:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.6 |4.4.7
--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-27 12:13:49 UTC ---
4.3 branch is being closed, moving to 4.4.7 target.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-06-27 13:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-30 16:26 [Bug other/43949] New: bogus warning: array subscript is above array bounds joachim dot reichel at gmx dot de
2010-04-30 17:25 ` [Bug other/43949] " rguenth at gcc dot gnu dot org
2010-05-01 21:30 ` rguenth at gcc dot gnu dot org
2010-05-01 21:31 ` [Bug tree-optimization/43949] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-05-04 9:54 ` rguenth at gcc dot gnu dot org
2010-05-14 12:58 ` rguenth at gcc dot gnu dot org
2010-05-21 9:12 ` joachim dot reichel at gmx dot de
2010-05-21 9:15 ` rguenther at suse dot de
2010-05-21 11:17 ` rguenth at gcc dot gnu dot org
2010-05-22 18:36 ` [Bug tree-optimization/43949] [4.3/4.4 " rguenth at gcc dot gnu dot org
[not found] <bug-43949-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 13:55 ` 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).