blob: ae38bbaced5e6bf445fe9893a1eb406f80893475 (
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
|
// Test throwing an exception whose constructor might throw. This tests that
// _cxa_free_exception is instrumented.
// { dg-do run }
// { dg-options "-fgnu-tm" }
void __attribute__ ((transaction_pure,noinline)) dontoptimize (int *i)
{ }
struct test
{
int* data;
test (int i)
{
// new may throw
data = new int[1];
data[0] = i;
dontoptimize (data);
}
test (const test& t) : test (t.data[0])
{ }
~test ()
{
delete data;
}
bool operator !=(const test& other)
{
return data[0] != other.data[0];
}
};
int main()
{
try
{
atomic_commit
{
throw test(23);
}
}
catch (test ex)
{
if (ex.data[0] != 23) __builtin_abort ();
}
return 0;
}
|