summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr49394.C
blob: 67d521f455821b80419c99a48a24782e353ec5ca (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
// { dg-do run }
// { dg-options "-fipa-pta -fnon-call-exceptions" }

struct Mutex
{
  bool locked;
  ~Mutex ()
  {
    if (locked)
      throw 0;
  }
  void lock ()
  {
    locked = true;
  }
  void unlock ()
  {
    if (!locked)
      throw 0;
    locked = false;
  }
};

struct lock_guard
{
  Mutex *m;
  lock_guard (Mutex *m) : m(m)
  {
  }
  ~lock_guard ()
  {
    m->unlock ();
  }
};

int
main ()
{
  Mutex m;
  m.lock ();
  try
  {
    lock_guard l (&m);
  }
  catch ( ...)
  {
    __builtin_abort ();
  }
  return 0;
}