gcc/testsuite/g++.dg/opt/pr61456.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-options "-O2 -std=c++11 -Werror=uninitialized" } |
| 3 | |
| 4 | int rand (); |
| 5 | |
| 6 | class Funcs |
| 7 | { |
| 8 | public: |
| 9 | int *f1 (); |
| 10 | int *f2 (); |
| 11 | }; |
| 12 | typedef decltype (&Funcs::f1) pfunc; |
| 13 | |
| 14 | static int Set (Funcs * f, const pfunc & fp) |
| 15 | { |
| 16 | (f->*fp) (); |
| 17 | return 0; |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | Foo () |
| 22 | { |
| 23 | pfunc fp = &Funcs::f1; |
| 24 | if (rand ()) |
| 25 | fp = &Funcs::f2; |
| 26 | Set (0, fp); |
| 27 | } |