2 // This testcase was miscompiled on IA-32 because a single stack slot
3 // was used for 2 different variables at the same time.
4 // The function H::h1 was miscompiled.
6 // { dg-options "-O2" }
8 extern "C" void abort (void);
9 extern "C" void exit (int);
15 bool a2 () { return !--a; }
21 B () : b (0) { a1 (); }
30 ~C () { if (c->a2 ()) { if (c == c0) c0 = 0; c->b1 (); } }
31 C &operator= (const C &);
32 static C c1 (const char *x, int y = -1);
41 template <class T> struct D
43 D (const T& t) : d (t) {}
49 template<class T> struct E
53 E (D<T> *p) : e (p) {}
54 E (const E<T>& x) : e (x.e) {}
55 const T& operator* () const { return e->d; }
56 T& operator* () { return e->d; }
57 bool operator== (const E<T>& x) const { return e == x.e; }
58 bool operator!= (const E<T>& x) const { return e != x.e; }
59 E<T> operator++ (int) { E<T> x = *this; e = e->next; return x; }
62 template <class T> struct F : public A
64 F () { f = new D<T>; f->next = f->prev = f; f0 = 0; }
69 F (const F<T>& x) : A ()
71 f = new D<T>; f->next = f->prev = f; f0 = 0;
79 E<T> f1 (E<T> x, const T& y)
81 D<T> *p = new D<T> (y);
91 template <class T> struct G
93 E<T> g1 () { g3 (); return E<T> (g->f); }
94 E<T> g2 (const T& x) { g3 (); return g->f1 (g1 (), x); }
95 void g3 () { if (g->a > 1) { g->a2 (); g = new F<T> (*g); } }
106 I (C r, C p) : i1 (r), i2 (p) {}
114 h.g2 (I (C::c1 ("s1"), C::c1 ("t")));
115 h.g2 (I (C::c1 ("s2"), C::c1 ("t")));
116 h.g2 (I (C::c1 ("s3"), C::c1 ("t")));
123 C C::c1 (const char *x, int y)
147 h.h.g = new F<H::I> ();
153 for (i = 0, p = h.h.g->f; i < 4; i++, p = p->next)
155 if (i == 0 && (p->d.i1.c != __null || p->d.i2.c != __null))
158 && (p->d.i1.c->b[0] != 's'
159 || p->d.i1.c->b[1] != '0' + i
160 || p->d.i1.c->b[2] != '\0'
161 || __builtin_strcmp (p->d.i2.c->b, "t")))
163 if (p->prev->next != p)
165 if (p->next->prev != p)
167 if (i == 3 && p->next != h.h.g->f)