diff mbox

[C++/68724] ICE with TRAIT_EXPR

Message ID 9291709a-a476-8d19-3b4c-2932c5752c4d@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Aug. 5, 2016, 12:24 p.m. UTC
I've committed this patch to fix a failed assertion.  unify's (pt.c) default 
case asserts EXPR_P(parm), but TRAIT_EXPR is tcc_exceptional, so fails.  However 
from unify's POV it's no more exceptional than, say, SIZEOF_EXPR, so should be 
allowed at that point.

nathan

Comments

Jason Merrill Aug. 5, 2016, 4:06 p.m. UTC | #1
On Fri, Aug 5, 2016 at 8:24 AM, Nathan Sidwell <nathan@acm.org> wrote:
> I've committed this patch to fix a failed assertion.  unify's (pt.c) default
> case asserts EXPR_P(parm), but TRAIT_EXPR is tcc_exceptional, so fails.
> However from unify's POV it's no more exceptional than, say, SIZEOF_EXPR, so
> should be allowed at that point.

Please also apply this to the relevant release branches.

Thanks,
Jason
Nathan Sidwell Aug. 5, 2016, 8:04 p.m. UTC | #2
On 08/05/16 12:06, Jason Merrill wrote:
> On Fri, Aug 5, 2016 at 8:24 AM, Nathan Sidwell <nathan@acm.org> wrote:
>> I've committed this patch to fix a failed assertion.  unify's (pt.c) default
>> case asserts EXPR_P(parm), but TRAIT_EXPR is tcc_exceptional, so fails.
>> However from unify's POV it's no more exceptional than, say, SIZEOF_EXPR, so
>> should be allowed at that point.
>
> Please also apply this to the relevant release branches.

committed to 5 & 6 branches.

nathan
diff mbox

Patch

2016-08-05  Nathan Sidwell  <nathan@acm.org>

	PR c++/68724
	* pt.c (unify): TRAIT_EXPR is an expr.

	PR c++/68724
	* g++.dg/cpp0x/pr68724.C: New.

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 239166)
+++ cp/pt.c	(working copy)
@@ -20269,7 +20269,7 @@  unify (tree tparms, tree targs, tree par
       /* An unresolved overload is a nondeduced context.  */
       if (is_overloaded_fn (parm) || type_unknown_p (parm))
 	return unify_success (explain_p);
-      gcc_assert (EXPR_P (parm));
+      gcc_assert (EXPR_P (parm) || TREE_CODE (parm) == TRAIT_EXPR);
     expr:
       /* We must be looking at an expression.  This can happen with
 	 something like:
Index: testsuite/g++.dg/cpp0x/pr68724.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr68724.C	(nonexistent)
+++ testsuite/g++.dg/cpp0x/pr68724.C	(working copy)
@@ -0,0 +1,15 @@ 
+// PR 68724 ICE in  unificiation
+// { dg-do compile { target c++11 } }
+
+template <typename _Tp, _Tp>
+struct integral_constant
+{
+};
+
+integral_constant<bool, true> inst;
+
+template <typename _Tp>
+struct integral_constant<bool, __is_enum(_Tp)> // { dg-error "" }
+{
+};
+