diff mbox

[C++] PR 58466

Message ID 52582CB8.7030008@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 11, 2013, 4:52 p.m. UTC
Hi,

this is just an ICE on invalid, but it's a 4_8/4_9 Regression, and, more 
importantly, we don't emit any sensible error message before ICEing. It 
manifests itself as TEMPLATE_PARM_INDEX unhandled by the main 
cxx_eval_constant_expression switch, and just adding the code to the 
bunch of those returned untouched leads to the same error message of 4_7 
and no ICE. Not sure at the moment whether something deeper is going on, 
though.

Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////////////
/cp
2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58466
	* semantics.c (cxx_eval_constant_expression): Handle 
	TEMPLATE_PARM_INDEX.

/testsuite
2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58466
	* g++.dg/cpp0x/variadic145.C: New.

Comments

Jason Merrill Oct. 11, 2013, 5:46 p.m. UTC | #1
How does a TEMPLATE_PARM_INDEX get this far?  It should have been 
detected as dependent before this.

Jason
Paolo Carlini Oct. 11, 2013, 6:29 p.m. UTC | #2
Hi,

On 10/11/2013 07:46 PM, Jason Merrill wrote:
> How does a TEMPLATE_PARM_INDEX get this far?  It should have been 
> detected as dependent before this.
Thanks. Interesting. We get there from the convert_nontype_argument call 
at line 6453 of pt.c (in convert_template_argument) , which is protected by:

       else if (!dependent_template_arg_p (orig_arg)
            && !uses_template_parms (t))

thus dependent_template_arg_p (orig_arg) returns *false* for that tree. 
This is trivially the case because dependent_template_arg_p begins:

   if (!processing_template_decl)
     return false;

thus it doesn't go that far when processing_template_decl is 0. 
Otherwise it would return true.

Is this information already useful to you? Are we maybe failing to bump 
processing_template_decl somewhere while processing the specialization?

Thanks!
Paolo.
diff mbox

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 203449)
+++ cp/semantics.c	(working copy)
@@ -9335,6 +9335,7 @@  cxx_eval_constant_expression (const constexpr_call
     case FUNCTION_DECL:
     case TEMPLATE_DECL:
     case LABEL_DECL:
+    case TEMPLATE_PARM_INDEX:
       return t;
 
     case PARM_DECL:
Index: testsuite/g++.dg/cpp0x/variadic145.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic145.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/variadic145.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/58466
+// { dg-do compile { target c++11 } }
+
+template<char, char...> struct A;
+
+template<typename> struct B;
+
+template<char... C> struct B<A<C...>> {};
+
+B<A<'X'>> b;        // { dg-error "incomplete type" }