This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/35966] New: array-subscript-above-bounds warning disappears when unrelated constructor definition is added
- From: "gcc-bugzilla at contacts dot eelis dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Apr 2008 14:12:58 -0000
- Subject: [Bug c++/35966] New: array-subscript-above-bounds warning disappears when unrelated constructor definition is added
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If I have the following three files:
/usr/include/blub.hpp:
struct Y { virtual ~Y(); };
struct X: Y { X(); };
t.cpp
#include <blub.hpp>
int main() { int i[3]; return i[3]; }
t2.cpp
#include <blub.hpp>
int main() { int i[3]; return i[3]; }
X::X() {}
then "g++ -O2 -Wall -c t.cpp" correctly warns
t.cpp:2: warning: array subscript is above array bounds
However, "g++ -O2 -Wall -c t2.cpp" is silent.
In other words, the warning disappears when X::X() is defined. This makes no
sense, because X has nothing to do with the array subscript.
Even weirder, the warning reappears if blub.hpp is either located elsewhere or
included manually by copy+paste-ing its contents.
Bug 35587 seems related, though it doesn't have the #include weirdness.
Problem is reproducible with gcc 4.3.0 20080106 (experimental) on SUSE 10.2,
and on Debian sid using the gcc-4.3 4.3.0-3 package.
--
Summary: array-subscript-above-bounds warning disappears when
unrelated constructor definition is added
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc-bugzilla at contacts dot eelis dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35966