gcc/testsuite/g++.old-deja/g++.martin/pmf2.C
raw| 1 | // { dg-do run } |
| 2 | // { dg-options "-Wno-pmf-conversions" } |
| 3 | // Test conversion of pointers to virtual member functions to |
| 4 | // pointers to non-member functions. |
| 5 | |
| 6 | struct A{ |
| 7 | int i; |
| 8 | A () :i(1){} |
| 9 | virtual void foo(); |
| 10 | }a; |
| 11 | |
| 12 | void A::foo() |
| 13 | { |
| 14 | i = 0; |
| 15 | } |
| 16 | |
| 17 | int main() |
| 18 | { |
| 19 | void (*f)(A*) = (void(*)(A*))(&A::foo); |
| 20 | f(&a); |
| 21 | return a.i; |
| 22 | } |