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-05-22 18:36 ` [Bug tree-optimization/43949] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
0 siblings, 1 reply; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2012-03-13 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-43949-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 13:55 ` [Bug tree-optimization/43949] [4.3/4.4 Regression] bogus warning: array subscript is above array bounds rguenth at gcc dot gnu.org
2012-03-13 17:00 ` [Bug tree-optimization/43949] [4.4 " jakub at gcc dot gnu.org
2010-04-30 16:26 [Bug other/43949] New: " joachim dot reichel at gmx dot de
2010-05-22 18:36 ` [Bug tree-optimization/43949] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot 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).