When deleting an array of dynamically allocated objects that inherit some base
class, a pointer offset calculation is modified during the optimization process
of a delete [] operator. The result is a subscript operation with a negative
index and this causes the warning to be emitted (erroneously I believe).
This was determined by analyzing the tree dump.
The file move_array.cpp.059t.dce2 has this code:
D.2208_15 = D.2171_6 + -8;
operator delete [] (D.2208_15);
turn into this in move_array.cpp.060t.forwprop2:
D.2208_15 = &(*D.2149_3)[-8];
operator delete [] (D.2208_15);
--
Summary: warning "array subscript is below array bounds" on
delete [] with -O2, -Wall
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris dot fairles at gmail dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36633