Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.other/union2.C

raw
1 // { dg-do run }
2 // Bug: g++ crashed on empty initializers for unions.
3 // Bug: gcc and g++ didn't zero unions with empty initializers.
4 // Submitted by J"orn Rennecke <[email protected]>
5
6 extern "C" void exit (int);
7
8 typedef union u
9 {
10 union u *up;
11 void *vp;
12 } u;
13
14 static u v = {};
15
16 void bar (u);
17 void baz (u);
18
19 void foo()
20 {
21 u w = {};
22 u x = { &v };
23 baz (x);
24 bar (w);
25 }
26
27 void baz (u w) { }
28
29 void bar (u w)
30 {
31 if (w.up)
32 exit (1);
33 }
34
35 int main ()
36 {
37 foo ();
38 return 0;
39 }