https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71834
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, the reason we are silent about the error is that we return error_mark_node out of: #0 0x00000000009e78c1 in coerce_template_parms (parms=<tree_vec 0x7fffefc122a8>, args=<tree_vec 0x7fffefc12b40>, in_decl=<template_decl 0x7fffefae7380 B>, complain=3, require_all_args=true, use_default_args=true) at ../../gcc/cp/pt.c:8278 #1 0x00000000009e7d11 in coerce_innermost_template_parms (parms=<tree_list 0x7fffefc122d0>, args=<tree_vec 0x7fffefc12b40>, in_decl=<template_decl 0x7fffefae7380 B>, complain=3, require_all_args=true, use_default_args=true) at ../../gcc/cp/pt.c:8371 #2 0x00000000009ea169 in lookup_template_class_1 (d1=<identifier_node 0x7fffefc117c0 B>, arglist=<tree_vec 0x7fffefc12b40>, in_decl=<tree 0x0>, context=<record_type 0x7fffefc13738 A>, entering_scope=0, complain=3) at ../../gcc/cp/pt.c:8816 #3 0x00000000009ec662 in lookup_template_class (d1=<template_decl 0x7fffefae7500 B>, arglist=<tree_vec 0x7fffefc10f80>, in_decl=<tree 0x0>, context=<tree 0x0>, entering_scope=0, complain=35) at ../../gcc/cp/pt.c:9162 #4 0x0000000000a6366a in finish_template_type (name=<template_decl 0x7fffefae7500 B>, args=<tree_vec 0x7fffefc10f80>, entering_scope=0) at ../../gcc/cp/semantics.c:3161 without actually diagnosing any error. The comment there says: else if (!arg) /* This only occurs if there was an error in the template parameter list itself (which we would already have reported) that we are trying to recover from, e.g., a class template with a parameter list such as template<typename..., typename>. */ ++lost; which has been added in r125062. So either this comment is wrong and we should emit some diagnostics here (what), or it is sometimes wrong and we should emit some diagnostics conditionally (what, under which condition), or it is correct and we should have diagnosed it earlier. Given that template <typename ..., typename> struct S {}; is diagnosed: pr71834-3.C:1:11: error: parameter pack ‘<template-parameter-1-1>’ must be at the end of the template parameter list I think we either need to just error here unconditionally and live with some hypothetical cases where we emit more errors than Doug wanted (though, I've tried: template <typename ..., typename> struct S {}; S <int> e; S <int, int> f; S <int, int, int> g; and in none of the cases it reaches this spot). The reason why if ((nargs - variadic_args_p > nparms && !variadic_p) || (nargs < nparms - variadic_p && require_all_args && !variadic_args_p && (!use_default_args || (TREE_VEC_ELT (parms, nargs) != error_mark_node && !TREE_PURPOSE (TREE_VEC_ELT (parms, nargs)))))) { if (complain & tf_error) { if (variadic_p || default_p) { nparms -= variadic_p + default_p; error ("wrong number of template arguments " "(%d, should be at least %d)", nargs, nparms); } else error ("wrong number of template arguments " "(%d, should be %d)", nargs, nparms); if (in_decl) inform (DECL_SOURCE_LOCATION (in_decl), "provided for %qD", in_decl); } return error_mark_node; } doesn't error in the #c0 case is that nargs is 1, nparms 2, variadic_p 1 and variadic_args_p is 0, so nargs < nparms - variadic_p is false. Jason?