-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht-silly-member-init.c
59 lines (48 loc) · 1001 Bytes
/
t-silly-member-init.c
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
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
struct Base {
int x;
int y;
};
struct Extend {
union {
int X;
struct Base bb;
} uu;
};
struct AlsoExtend {
struct Base bb;
int z;
};
static struct Extend Works = {
.uu.bb.x = 5,
.uu.bb.y = 3,
};
/*
* obvious abuse of "union" rules!
*/
static struct Extend Breaks = {
.uu.bb.x = 5,
.uu.bb.y = 3,
.uu.X = 2
};
static struct AlsoExtend AlsoWorks = {
.bb.x = 5,
.bb.y = 3,
.z = 69
};
int main(void);
int
main()
{
printf("Works: x:%d y:%d X:%d\n", Works.uu.bb.x, Works.uu.bb.y, Works.uu.X);
printf("Breaks: x:%d y:%d X:%d\n", Breaks.uu.bb.x, Breaks.uu.bb.y, Breaks.uu.X);
printf("AlsoWorks: x:%d y:%d z:%d\n", AlsoWorks.bb.x, AlsoWorks.bb.y, AlsoWorks.z);
exit(0);
}
/*
* Local Variables:
* eval: (make-local-variable 'compile-command)
* compile-command: (let ((fn (file-name-sans-extension (file-name-nondirectory (buffer-file-name))))) (concat "rm -f " fn "; " (default-value 'compile-command) " " fn " && ./" fn))
* End:
*/