1 // This testcase was miscompiled on IA-64 to read from unitialized memory
4 // { dg-options "-O2" }
10 bool a2 () { return !--a; }
16 template <class T> struct C
19 C (const T& t) : c (t) {}
24 template <class T> struct D
28 D (C<T> *x) : d (x) {}
29 D (const D<T>& x) : d (x.d) {}
30 bool operator!= (const D<T>& x) const { return d != x.d; }
31 const T& operator* () const { return d->c; }
32 D<T> operator++ (int) { D<T> t = *this; d = d->next; return t; }
35 template <class T> struct E
39 E (C<T> *p) : e (p) {}
40 E (const E<T>& x) : e (x.e) {}
41 E (const D<T>& x) : e (x.e) {}
42 bool operator!= (const E<T>& x) const { return e != x.e; }
43 const T& operator* () const { return e->c; }
44 E<T>& operator++ () { e = e->next; return *this; }
47 template <class T> struct F : public A
51 F () { f = new C<T>; f->next = f->prev = f; f0 = 0; }
52 F (const F<T>& x) : A ()
54 f = new C<T>; f->next = f->prev = f; f0 = 0;
55 D<T> b (x.f->next), e (x.f), i (f);
72 D<T> f1 (D<T> x, const T& y)
74 C<T> *p = new C<T> (y);
84 template <class T> struct G
87 G () { g = new F<T>; }
88 G (const G<T>& x) { g = x.g; g->a1 (); }
90 G<T>& operator= (const G<T>& x) { x.g->a1 (); g = x.g; return *this; }
91 D<T> g1 () { g4 (); return D<T> (g->f); }
92 E<T> g1 () const { return E<T> (g->f); }
93 E<T> g2 () const { return E<T> (g->f->next); }
94 D<T> g3 (const T& x) { g4 (); return g->f1 (g1 (), x); }
95 void g4 () { if (g->a > 1) { g->a2 (); g = new F<T> (*g); } }
97 G<T> operator+ (const G<T>& x) const
100 for (E<T> i = x.g2 (); i != x.g1 (); ++i)
105 G<T>& operator+= (const G<T>& x)
107 for (E<T> i = x.g2 (); i != x.g1 (); ++i)
113 struct H : public G<B>
116 H (const H& x) : G<B> (x) {}
117 H (const G<B>& x) : G<B> (x) {}