gcc/testsuite/g++.dg/overload/defarg8.C
raw| 1 | // PR c++/60367 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | extern "C" int printf (const char *, ...); |
| 5 | extern "C" void abort(); |
| 6 | |
| 7 | void *p; |
| 8 | struct foo { |
| 9 | foo() { p = this; } |
| 10 | foo (const foo &) { abort(); } |
| 11 | ~foo() { if (p != this) abort(); } |
| 12 | }; |
| 13 | |
| 14 | void do_something( foo f = {} ) |
| 15 | { |
| 16 | if (&f != p) abort(); |
| 17 | } |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | do_something(); |
| 22 | } |