summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/pr15054.C
blob: cfc48cf2498946d2d1bdf053b9bcce5996e40c36 (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
// PR middle-end/15054
// This used to abort due to overlapping stack temporaries.

// { dg-do run }
// { dg-options "-O" }

extern "C" void abort (void);

struct pointer
{
  void* ptr;

  pointer(void* x = 0) : ptr(x) {}
  pointer(const pointer& x) : ptr(x.ptr) {}
};

struct element
{
  int canary;

  element() : canary(123) { }
  ~element() { pointer(); if (canary != 123) abort (); }
};

inline pointer
insert(const element& x)
{
  return pointer(new element(x));
}

int
main (void)
{
  insert(element());
  return 0;
}