aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/expr/cond16.C
blob: 796828b25c06a21b4f223bbf9115d336b780ca0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// PR c++/90393
// { dg-do run }

int c, d;

struct string {
  string(const char *p): s(p) { ++c; }
  ~string() { ++d; }
  string(const string& str): s(str.s) { ++c; }
  const char* s;
  bool empty() const { return !s; }
};
    
string foo()
{
  string s("foo");
  return s.empty() ? throw "empty" : s;
}

int main()
{
  foo();
  if (c != d)
    __builtin_abort();
}