2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / union2.C
blob5c2d7dcac7236599359b7c7621b7f7258a34b2bb
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 <amylaar@cygnus.co.uk>
6 extern "C" void exit (int);
8 typedef union u
10   union u *up;
11   void *vp;
12 } u;
14 static u v = {};
16 void bar (u);
17 void baz (u);
19 void foo()
21        u w = {};
22        u x = { &v };
23        baz (x);
24        bar (w);
27 void baz (u w) { }
29 void bar (u w)
31   if (w.up)
32     exit (1);
35 int main ()
37   foo ();
38   return 0;