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