1 // { dg-do run }
2 
3 // Small test case from povray, see if it reproduces.
4 
5 #include <stdio.h>
6 
7 class POVMS_MessageReceiver
8 {
9 
10 private:
11    int x;
12    class Handler
13    {
14       public:
15          virtual void print() = 0;
16    };
17 protected:
18    template<class T> class MemberHandler : public Handler
19    {
20    public:
MemberHandler(T * xx)21       MemberHandler(T *xx)
22       {
23         x = xx;
24       }
25 
~MemberHandler()26       ~MemberHandler() {}
27 
print()28       void print()
29       {
30          printf("In print\n");
31       }
32   private:
33       T *x;
34    };
35 
36 private:
37    struct HandlerNode
38    {
39       Handler *handler;
40    };
41 
42    HandlerNode *receiver;
43 public:
POVMS_MessageReceiver(int xx)44    POVMS_MessageReceiver(int xx) : x(xx) {}
~POVMS_MessageReceiver()45    ~POVMS_MessageReceiver() {}
46 
47    void foo(int *xx);
48    void try_call();
49 };
50 
foo(int * xx)51 void POVMS_MessageReceiver::foo(int *xx)
52 {
53    receiver = new HandlerNode;
54 
55    receiver->handler = new MemberHandler<int>(xx);
56 }
57 
try_call()58 void POVMS_MessageReceiver::try_call()
59 {
60    receiver->handler->print();
61 }
62 
63 
main()64 int main()
65 {
66    int loc = 34;
67    POVMS_MessageReceiver a_test(100);
68 
69    a_test.foo(&loc);
70    a_test.try_call();
71 }
72 
73 
74 
75