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++/32546] New: 'warning: array subscript is above/below array bounds' on delete[]


I got the 'below array bounds' warning in some code and could reduce it to the
following testcase (which results in the 'above array bounds' warning). The
warning occurs with optimization level -O2 and above.

gcc version 4.3.0 20070622 (experimental)

g++-4.3 -c -W -Wall -O2 asiaab.cpp --save-temps
asiaab.cpp: In function 'void f()':
asiaab.cpp:5: warning: array subscript is above array bounds

================
#include <vector>
void g()
{
        std::vector<int> *A = new std::vector<int>[42];
        delete[] A;
}
================

The warning does not occur with types e.g. 'int' or 'std::pair<int,int>'
instead of 'std::vector<int>'.


-- 
           Summary: 'warning: array subscript is above/below array bounds'
                    on delete[]
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at abeckmann dot de
  GCC host triplet: i486-linux-gnu


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


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