1 // PR c++/36364
2 // { dg-options "-frepo" }
3 // { dg-final { cleanup-repo-files } }
4 // { dg-require-host-local "" }
5 // { dg-skip-if "dkms are not final links" { vxworks_kernel } }
6 
7 template <typename C> struct A
8 {
assignA9   static void assign (C &c1, const C &c2) { c1 = c2; }
10 };
11 
12 template <typename C, typename T> struct B
13 {
14   struct D
15   {
16     static const C terminal;
17     static unsigned long stor[];
empty_repB::D18     static D &empty_rep ()
19     {
20       void *p = reinterpret_cast <void *>(&stor);
21       return *reinterpret_cast <D *>(p);
22     }
testB::D23     void test (unsigned long n)
24     {
25       T::assign (this->refdata ()[n], terminal);
26     }
refdataB::D27     C *refdata () throw ()
28     {
29       return reinterpret_cast <C *>(this + 1);
30     }
31   };
32   C *dataplus;
dataB33   C *data () const { return dataplus; }
repB34   D *rep () const { return &((reinterpret_cast < D * >(data ()))[-1]); }
empty_repB35   static D & empty_rep () { return D::empty_rep (); }
BB36   B () : dataplus (empty_rep ().refdata ()) { }
~BB37   ~B () { }
push_backB38   void push_back (C c) { rep ()->test (10); }
39 };
40 
41 template <typename C, typename T> const C B <C, T>::D::terminal = C ();
42 template <typename C, typename T> unsigned long B <C, T>::D::stor[64];
43 
44 int
main()45 main ()
46 {
47   B <char, A <char> > s;
48   s.push_back ('a');
49 }
50