1// { dg-do run  }
2struct S;
3
4template <S* (S::*p)()>
5struct F {
6  S* f (S& s)
7    {
8      return (s.*p)();
9    }
10};
11
12template <int S::*p>
13struct D {
14  void d (S& s)
15    {
16      (s.*p) = 3;
17    }
18};
19
20struct S {
21  S* g ();
22  int i;
23  F<&S::g> fg;
24  D<&S::i> di;
25  S* h(), k(F<&S::h>);
26  F<&S::g> fg2;
27  D<&S::i> di2;
28};
29
30S* S::g()
31{
32  return this;
33}
34
35S* S::h()
36{
37  return this;
38}
39
40int main()
41{
42  S s;
43  s.i = 2;
44  s.di.d (s);
45  if (s.i != 3)
46    return 1;
47  if (s.fg2.f(s) != &s)
48    return 1;
49}
50