| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
// Copyright (C) 2003 Free Software Foundation, Inc. |
| 4 |
// Contributed by Nathan Sidwell 19 Apr 2003 <[email protected]> |
| 5 |
|
| 6 |
// PR 9881. address-constant-expression not static initialized |
| 7 |
|
| 8 |
struct bar { |
| 9 |
double p; |
| 10 |
}; // bar |
| 11 |
|
| 12 |
bar v; |
| 13 |
static bool error = false; |
| 14 |
|
| 15 |
struct foo { |
| 16 |
static double *a; |
| 17 |
static double *b; |
| 18 |
static double storage; |
| 19 |
}; |
| 20 |
|
| 21 |
struct baz { |
| 22 |
baz () { |
| 23 |
if (foo::a != &v.p) |
| 24 |
error = true; |
| 25 |
if (foo::b != &foo::storage) |
| 26 |
error = true; |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
baz f; // Get constructor to run before any other non-static initializers |
| 31 |
|
| 32 |
double *foo::a = &(((bar *)(&v))->p); |
| 33 |
double *foo::b = &(((bar *)(&foo::storage))->p); |
| 34 |
double foo::storage = 0.0; |
| 35 |
|
| 36 |
int main() { |
| 37 |
return error; |
| 38 |
} |