This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/84720, ICE with rvalue ref template parameter
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 16 Mar 2018 14:54:41 -0400
- Subject: Re: C++ PATCH for c++/84720, ICE with rvalue ref template parameter
- References: <CADzB+2m3J9W_c5hFGDgCfpCY8Ttq8jv3qFGz2ZshsKcG5xo=zw@mail.gmail.com>
On Tue, Mar 13, 2018 at 2:54 PM, Jason Merrill <jason@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 <jason@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() {