PR c++/89212 - ICE converting nullptr to pointer-to-member-function.

* pt.c (tsubst_copy_and_build) <case CONSTRUCTOR>: Return early for
	null member pointer value.

	* g++.dg/cpp0x/nullptr40.C: New test.
	* g++.dg/cpp0x/nullptr41.C: New test.

From-SVN: r268781
This commit is contained in:
Marek Polacek 2019-02-11 20:03:43 +00:00 committed by Marek Polacek
parent 75c5639de1
commit ab97c3cdaf
5 changed files with 56 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2019-02-11 Marek Polacek <polacek@redhat.com>
PR c++/89212 - ICE converting nullptr to pointer-to-member-function.
* pt.c (tsubst_copy_and_build) <case CONSTRUCTOR>: Return early for
null member pointer value.
2019-02-11 Jakub Jelinek <jakub@redhat.com>
PR c++/88977

View file

@ -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)

View file

@ -1,3 +1,9 @@
2019-02-11 Marek Polacek <polacek@redhat.com>
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 <jakub@redhat.com>
PR c++/88977

View file

@ -0,0 +1,19 @@
// PR c++/89212
// { dg-do compile { target c++11 } }
template <int, typename T> using enable_if_t = int;
template<class X, void(X::*foo)() = nullptr>
struct p
{
template<void(X::*fun)() = foo, typename T = enable_if_t<nullptr == fun, int>>
p(T) { }
p() = default;
};
struct A
{
p<A> i = 1;
void bar();
p<A, &A::bar> j;
};

View file

@ -0,0 +1,19 @@
// PR c++/89212
// { dg-do compile { target c++11 } }
template <int, typename T> using enable_if_t = int;
template<typename U, typename W, typename Y, class X, W(X::*foo)() = nullptr>
struct p
{
template<U(Y::*fun)() = foo, typename T = enable_if_t<nullptr == fun, int>>
p(T) { }
p() = default;
};
struct A
{
p<void, void, A, A> i = 1;
void bar();
p<void, void, A, A, &A::bar> j;
};