]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/init/no-elide2.C
c++: missing dtor with -fno-elide-constructors [PR100838]
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / init / no-elide2.C
1 // PR c++/100838
2 // { dg-do run }
3 // { dg-additional-options -fno-elide-constructors }
4
5 extern "C" int puts (const char *);
6
7 int c,d;
8 class MyString {
9 public:
10 MyString(const char* s = "") {
11 puts ("ctor");
12 ++c;
13 }
14 ~MyString() {
15 puts ("dtor");
16 ++d;
17 }
18 MyString(const MyString& s) {
19 puts ("copy ctor");
20 ++c;
21 }
22 MyString& operator=(const MyString& s);
23 };
24
25 int main() {
26 {
27 MyString s1 = "Hello";
28 puts ("main");
29 }
30 if (c != d)
31 __builtin_abort();
32 }