repo.or.cz
/
gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Fortran: Fix PR 47485.
[gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
union3.C
blob
d95d30c6fe3ec23fd5b97c7f703287310e1275d1
1
// Runtime test for C++11 unrestricted unions
2
// { dg-do run { target c++11 } }
3
4
int c, d;
5
struct A
6
{
7
int i;
8
A(): i(1) { ++c; }
9
A(const A&): i(2) { ++c; }
10
~A() { ++d; }
11
};
12
13
union B
14
{
15
A a;
16
B() { }
17
B(const B& b) { }
18
~B() { }
19
};
20
21
struct C
22
{
23
union { A a; };
24
C() { }
25
C(const C&) { }
26
~C() { }
27
};
28
29
union D
30
{
31
A a;
32
D(): a() { }
33
D(const D& d): a(d.a) { }
34
~D() { a.~A(); }
35
};
36
37
struct E
38
{
39
union { A a; };
40
E(): a() { }
41
E(const E& e): a (e.a) { }
42
~E() { a.~A(); }
43
};
44
45
int main()
46
{
47
{
48
B b1;
49
B b2(b1);
50
51
C c1;
52
C c2(c1);
53
}
54
55
if (c != 0 || d != 0)
56
return c+d*10;
57
58
{
59
D d1;
60
D d2(d1);
61
62
E e1;
63
E e2(e1);
64
}
65
66
if (c != 4 || d != 4)
67
return c*100+d*1000;
68
}