view gcc/testsuite/g++.dg/other/ptrmem10.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin PR c++/37093

template <class C, void (C::*M) ()>
static
void foo(void *obj)
{
  C *p = static_cast<C*>(obj);
  (p->*M)();
}

template <class C>
static void
bar(C *c, void (C::*m) ())
{
  foo<C,m>((void *)c);// { dg-error "(not a valid template arg|pointer-to-member|no matching fun|could not convert|constant)" }
}

struct S
{
  void baz () {}
};

int
main ()
{
  S a;
  bar(&a, &S::baz);
}