1 // PR c++/17670 2 // { dg-do run } 3 4 #include <cstdlib> 5 #include <new> 6 7 bool abort_new; 8 void *operator new[](size_t bytes) throw (std::bad_alloc) { 9 if (abort_new) 10 abort(); 11 return operator new (bytes); 12 } 13 14 15 struct X {}; 16 int main () { 17 // Do not abort until int main is running in case startup code uses 18 // operator new[]. 19 abort_new = true; 20 new (X); 21 } 22