This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/35966] New: array-subscript-above-bounds warning disappears when unrelated constructor definition is added


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]