aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/pr98499.C
blob: ace088aeed9e942e761f30396e5cc5f997ccf4ba (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
/* PR tree-optimization/98499.  */
/* { dg-do run } */
/* { dg-options "-O2" } */

struct string {
  // pointer to local store
  char * _M_buf;
  // local store
  char _M_local_buf[16];

  __attribute__((noinline)) string() : _M_buf(_M_local_buf) {}

  ~string() {
    if (_M_buf != _M_local_buf)
      __builtin_trap();
  }

  string(const string &__str); // no copies
};

__attribute__((noinline)) static string dir_name() { return string(); }
class Importer {
  string base_path;

public:
  __attribute__((noinline)) Importer() : base_path (dir_name()) {}
};

int main() {
  Importer imp;
}