1 // { dg-do run  }
2 // Bug: g++ expanded b->member() multiple times, causing the optimizer to
3 // decide that things weren't related and optimize 'die' into an infinite
4 // loop.
5 
6 struct A {
~AA7   virtual ~A() { }
fA8   void f (bool) { }
9 };
10 
11 typedef void (A::*pmf_void)();
12 typedef void (A::*pmf_bool)(bool);
13 
14 struct B {
~BB15   ~B() {}
memberB16   pmf_void member() const { return mbr; }
17   pmf_void mbr;
18 };
19 
20 A *a;
21 B *b;
22 
die(bool param)23 void die (bool param) {
24   pmf_bool pmf = (pmf_bool)(b->member());
25   (a->*pmf)(param);
26 }
27 
main()28 int main ()
29 {
30   A a2;
31   B b2;
32 
33   b2.mbr = reinterpret_cast<pmf_void>(&A::f);
34 
35   a = &a2;
36   b = &b2;
37 
38   die (true);
39 }
40