2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / init / addr-const1.C
blob3b4637a4144e59ff2ddf1571c62fe9aa9513a9ad
1 // { dg-do run }
3 // Copyright (C) 2003 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 19 Apr 2003 <nathan@codesourcery.com>
6 // PR 9881. address-constant-expression not static initialized
8 struct bar {
9   double p;
10 }; // bar
11     
12 bar v;
13 static bool error = false;
15 struct foo {
16   static double *a;
17   static double *b;
18   static double storage;
21 struct baz {
22   baz () {
23     if (foo::a != &v.p)
24       error = true;
25     if (foo::b != &foo::storage)
26       error = true;
27   }
30 baz f; // Get constructor to run before any other non-static initializers
32 double *foo::a = &(((bar *)(&v))->p);
33 double *foo::b = &(((bar *)(&foo::storage))->p);
34 double foo::storage = 0.0;
36 int main() {
37   return error;