http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52156
Bug #: 52156 Summary: add warning for allocated array being converted to pointer to base Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: diagnostic Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: r...@gcc.gnu.org struct B { int i; B() : i(0) { } }; struct D : B { int j; D() : j(1) { }}; int main() { B* b = new D[2]; // warning return b[1].i; } It might be a good idea to warn about this code, the allocated array cannot be safely indexed or deleted through any type except D* There should be a warning if a new-expression allocates an array of D and the result undergoes pointer conversion to a type that is not cv D*