d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail11151.d
blobe5c262272a22b35801c1f6d9d2c02aea4b99f779
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail11151.d(30): Error: overlapping initialization for field `a` and `y`
5 ---
6 */
8 //extern(C) int printf(const char*, ...);
10 union U
12 struct
14 align(1) long a;
15 align(1) int b;
17 struct
19 align(1) int x;
20 align(1) long y;
23 void main()
25 static assert(U.a.offsetof == 0);
26 static assert(U.b.offsetof == 8);
27 static assert(U.x.offsetof == 0);
28 static assert(U.y.offsetof == 4);
30 U u = {a:1, y:2}; // overlapped initializing U.a and U.y
32 //printf("u.a = %lld\n", u.a); // 8589934593 , Wrong!
33 //printf("u.b = %d\n", u.b); // 0
34 //printf("u.x = %d\n", u.x); // 1
35 //printf("u.y = %lld\n", u.y); // 2