gcc/testsuite/g++.dg/expr/cond16.C
raw| 1 | // PR c++/90393 |
| 2 | // { dg-do run } |
| 3 | |
| 4 | int c, d; |
| 5 | |
| 6 | struct string { |
| 7 | string(const char *p): s(p) { ++c; } |
| 8 | ~string() { ++d; } |
| 9 | string(const string& str): s(str.s) { ++c; } |
| 10 | const char* s; |
| 11 | bool empty() const { return !s; } |
| 12 | }; |
| 13 | |
| 14 | string foo() |
| 15 | { |
| 16 | string s("foo"); |
| 17 | return s.empty() ? throw "empty" : s; |
| 18 | } |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | foo(); |
| 23 | if (c != d) |
| 24 | __builtin_abort(); |
| 25 | } |