Now that we return the original CONSTRUCTOR from finish_compound_literal, the call to null_member_pointer_value_p in tsubst_copy_and_build was getting confused because the CONSTRUCTOR was still empty rather than a valid PMF value. This is a regression from GCC 8.
Tested x86_64-pc-linux-gnu, applying to trunk. * call.c (null_member_pointer_value_p): Handle an empty CONSTRUCTOR of PMF type. --- gcc/cp/call.c | 1 + gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C | 20 ++++++++++++++++++++ gcc/cp/ChangeLog | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 519dad9bf2c..9582345d7e8 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -569,6 +569,7 @@ null_member_pointer_value_p (tree t) return false; else if (TYPE_PTRMEMFUNC_P (type)) return (TREE_CODE (t) == CONSTRUCTOR + && CONSTRUCTOR_NELTS (t) && integer_zerop (CONSTRUCTOR_ELT (t, 0)->value)); else if (TYPE_PTRDATAMEM_P (type)) return integer_all_onesp (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C new file mode 100644 index 00000000000..3035fefbc5f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +struct A +{ + void f(); +}; + +using ftype = decltype(&A::f); + +template <class T> +bool f() +{ + ftype p = ftype{}; + return p; +} + +int main() +{ + f<int>(); +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e63fdaac74..8b2e7574450 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-04-12 Jason Merrill <ja...@redhat.com> + + * call.c (null_member_pointer_value_p): Handle an empty CONSTRUCTOR + of PMF type. + 2019-04-12 Marek Polacek <pola...@redhat.com> * except.c (build_noexcept_spec): Use build_converted_constant_bool_expr base-commit: 5dcfd55433d543c73c774936a0979e463b9dc9b6 -- 2.20.1