aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/elide3.C
blob: 7eb0389a3f68291963396e45ab59847788035b49 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// PR c++/67557
// { dg-do run }

namespace std
{
  struct string
  {
    typedef unsigned long size_type;
    const char* _M_p;
    char        _M_local_buf[1];

    string(const char* s) : _M_p(_M_local_buf)
    {
      __builtin_printf("%p constructed\n", this);
    }

    string(const string& s) : _M_p(_M_local_buf)
    {
      __builtin_printf("%p copied from %p\n", this, &s);
    }

    ~string()
    {
      __builtin_printf("%p destroyed\n", this);
      if (_M_p != _M_local_buf)
	__builtin_abort();
    }
  };
}

struct StartTag
{
  explicit StartTag(std::string const & tag) : tag_(tag), keepempty_(false) {}
  std::string tag_;
  bool keepempty_;
};

StartTag fontToStartTag() { return StartTag(""); }

struct FontTag : public StartTag
{
  FontTag() : StartTag(fontToStartTag()) {}
};

int main()
{
  FontTag x;
  __builtin_printf("%p x.tag_ in main()\n", &x.tag_);
  return 0;
}