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)
9 #if __cplusplus <= 199711L
throw(std::bad_alloc)10   throw (std::bad_alloc)
11 #endif
12 {
13   if (abort_new)
14     abort();
15   return operator new (bytes);
16 }
17 
18 
19 struct X {};
main()20 int main () {
21   // Do not abort until main is running in case startup code uses
22   // operator new[].
23   abort_new = true;
24   new (X);
25 }
26