aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/union_initialization.d
blob: 96c2bf459997321cf93db1df401fe145e50922a2 (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
// https://issues.dlang.org/show_bug.cgi?id=20068

union B
{
	int i;
	int* p;
	@safe this(int* p)
	{
		// Error: cannot access pointers in @safe code that overlap other fields
		this.p = p;
	}
}

/**************************************************************/
// https://issues.dlang.org/show_bug.cgi?id=21229

struct NeedsInit
{
	int var;
	@disable this();
}

union Union
{
	NeedsInit ni;
}

union Proxy
{
	Union union_;
}

struct S
{
	Union union_;
	Proxy proxy;

	this(NeedsInit arg)
	{
		union_.ni = arg;
		proxy.union_.ni = arg;
	}
}