From: Marek Polacek Date: Mon, 11 Feb 2019 20:03:43 +0000 (+0000) Subject: PR c++/89212 - ICE converting nullptr to pointer-to-member-function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab97c3cdaf837637722237a4d1c33ddfdf6f7ee7;p=gcc.git PR c++/89212 - ICE converting nullptr to pointer-to-member-function. * pt.c (tsubst_copy_and_build) : Return early for null member pointer value. * g++.dg/cpp0x/nullptr40.C: New test. * g++.dg/cpp0x/nullptr41.C: New test. From-SVN: r268781 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3bfd06fab29..3d3bb2ace9a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-02-11 Marek Polacek + + PR c++/89212 - ICE converting nullptr to pointer-to-member-function. + * pt.c (tsubst_copy_and_build) : Return early for + null member pointer value. + 2019-02-11 Jakub Jelinek PR c++/88977 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eb1797658c5..184cb851145 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19253,6 +19253,12 @@ tsubst_copy_and_build (tree t, looked up by digest_init. */ process_index_p = !(type && MAYBE_CLASS_TYPE_P (type)); + if (null_member_pointer_value_p (t)) + { + gcc_assert (same_type_p (type, TREE_TYPE (t))); + RETURN (t); + } + n = vec_safe_copy (CONSTRUCTOR_ELTS (t)); newlen = vec_safe_length (n); FOR_EACH_VEC_SAFE_ELT (n, idx, ce) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index afcf630d6de..ae04c4bb692 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-02-11 Marek Polacek + + PR c++/89212 - ICE converting nullptr to pointer-to-member-function. + * g++.dg/cpp0x/nullptr40.C: New test. + * g++.dg/cpp0x/nullptr41.C: New test. + 2019-02-11 Jakub Jelinek PR c++/88977 diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr40.C b/gcc/testsuite/g++.dg/cpp0x/nullptr40.C new file mode 100644 index 00000000000..21c188bdb5e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr40.C @@ -0,0 +1,19 @@ +// PR c++/89212 +// { dg-do compile { target c++11 } } + +template using enable_if_t = int; + +template +struct p +{ + template> + p(T) { } + p() = default; +}; + +struct A +{ + p i = 1; + void bar(); + p j; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr41.C b/gcc/testsuite/g++.dg/cpp0x/nullptr41.C new file mode 100644 index 00000000000..54e66af2095 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr41.C @@ -0,0 +1,19 @@ +// PR c++/89212 +// { dg-do compile { target c++11 } } + +template using enable_if_t = int; + +template +struct p +{ + template> + p(T) { } + p() = default; +}; + +struct A +{ + p i = 1; + void bar(); + p j; +};