1// Copyright (C) 1999 Free Software Foundation, Inc.
2// Contributed by Nathan Sidwell 14 Jan 1999 <nathan@acm.org>
3
4// Make sure objects with mutable members are never placed in a read only
5// section.
6
7// All these are POD structs, and hence do not need ctors
8struct A { mutable int i; };
9struct B { A a; };
10struct C { A a[1]; };
11struct D { static A const a; };
12
13// all these are static consts and hence naively suitable for a read only
14// section. But they contain a mutable, so must be in a writable section.
15static int const i = 0;
16static A const a = {0};
17static B const b = {{0}};
18static C const c = {{{0}}};
19static A const aa[] = {{0}};
20static B const bb[] = {{{0}}};
21static C const cc[] = {{{{0}}}};
22A const D::a = {0};
23
24int main()
25{
26  a.i = 05;
27  b.a.i = 05;
28  c.a[0].i = 05;
29  aa[0].i = 05;
30  bb[0].a.i = 05;
31  cc[0].a[0].i = 05;
32  D::a.i = 05;
33
34  if(!a.i) return 1;
35  if(!b.a.i) return 1;
36  if(!c.a[0].i) return 1;
37  if(!aa[0].i) return 1;
38  if(!bb[0].a.i) return 1;
39  if(!cc[0].a[0].i) return 1;
40  if(!D::a.i) return 1;
41
42  return 0;
43}
44