On Tue, Mar 13, 2018 at 2:54 PM, Jason Merrill <ja...@redhat.com> wrote: > It's unclear to me that it is ever possible to instantiate a template > taking an rvalue ref parameter, but I guess we might as well handle it > properly.
...except that such parameters are actually ill-formed, so we should reject.
commit dea7cfdf2f1e7f17befbe3987badba9f74a6b2b9 Author: Jason Merrill <ja...@redhat.com> Date: Fri Mar 16 14:01:14 2018 -0400 PR c++/84720 - ICE with rvalue ref non-type argument. * pt.c (invalid_nontype_parm_type_p): Prohibit rvalue reference. (convert_nontype_argument): Revert earlier change. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6c96424152e..f7b1b0dd9aa 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23985,7 +23985,10 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) { if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) return false; - else if (POINTER_TYPE_P (type)) + else if (TYPE_PTR_P (type)) + return false; + else if (TREE_CODE (type) == REFERENCE_TYPE + && !TYPE_REF_IS_RVALUE (type)) return false; else if (TYPE_PTRMEM_P (type)) return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C index b8e0daba0f7..06516dfa2b9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C @@ -1,7 +1,7 @@ // PR c++/84720 // { dg-do compile { target c++11 } } -template<int &&> +template<int &&> // { dg-error "not a valid type" } struct a { template<typename...> static void b() {