gcc/testsuite/g++.old-deja/g++.mike/net46.C
raw| 1 | // { dg-do run } |
| 2 | // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } } |
| 3 | #include <iostream> |
| 4 | #include <cstdlib> |
| 5 | #include <cstddef> |
| 6 | #include <new> |
| 7 | |
| 8 | int fail = 1; |
| 9 | |
| 10 | int in_main = 0; |
| 11 | |
| 12 | void *operator new(size_t size) |
| 13 | #if __cplusplus <= 199711L |
| 14 | throw (std::bad_alloc) |
| 15 | #endif |
| 16 | { |
| 17 | if (!in_main) return malloc (size); |
| 18 | --fail; |
| 19 | return (void*) 0; |
| 20 | } |
| 21 | |
| 22 | int main() { |
| 23 | std::cout << ""; |
| 24 | in_main = 1; |
| 25 | new int; |
| 26 | return fail; |
| 27 | } |