aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/no-elide2.C
blob: 9a0ba1936ab7b9ad879f9ab2237d52b3fcd30c03 (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
26
27
28
29
30
31
32
// PR c++/100838
// { dg-do run }
// { dg-additional-options -fno-elide-constructors }

extern "C" int puts (const char *);

int c,d;
class MyString {
public:
  MyString(const char* s = "") {
    puts ("ctor");
    ++c;
  }
  ~MyString() {
    puts ("dtor");
    ++d;
  }
  MyString(const MyString& s) {
    puts ("copy ctor");
    ++c;
  }
  MyString& operator=(const MyString& s);
};

int main() {
  {
    MyString s1 = "Hello";
    puts ("main");
  }
  if (c != d)
    __builtin_abort();
}