[C++ Patch] PR 80449 ("[7/8 Regression] ICE reporting failed partial class template specialization class template argument deduction")
Paolo Carlini
paolo.carlini@oracle.com
Mon Oct 23 21:21:00 GMT 2017
Hi,
this issue is by and large a duplicate of C++/79790, which I already
fixed. There is a minor remaining nit: for the testcase, after the correct:
   error: cannot deduce template arguments of âC<S>â, as it has no
viable deduction guides
we also emit the meaningless:
   error: too many initializers for â<type error>â
only because in finish_compound_literal we don't check - as we do in
most other places - the return value of do_auto_deduction for
error_mark_node and it filters through until reshape_init. Tested
x86_64-linux.
Thanks, Paolo.
////////////////////
-------------- next part --------------
/cp
2017-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80449
* semantics.c (finish_compound_literal): Check do_auto_deduction
return value for error_mark_node.
/testsuite
2017-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80449
* g++.dg/cpp1z/class-deduction46.C: New.
-------------- next part --------------
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 254005)
+++ cp/semantics.c (working copy)
@@ -2711,8 +2711,12 @@ finish_compound_literal (tree type, tree compound_
if (tree anode = type_uses_auto (type))
if (CLASS_PLACEHOLDER_TEMPLATE (anode))
- type = do_auto_deduction (type, compound_literal, anode, complain,
- adc_variable_type);
+ {
+ type = do_auto_deduction (type, compound_literal, anode, complain,
+ adc_variable_type);
+ if (type == error_mark_node)
+ return error_mark_node;
+ }
if (processing_template_decl)
{
Index: testsuite/g++.dg/cpp1z/class-deduction46.C
===================================================================
--- testsuite/g++.dg/cpp1z/class-deduction46.C (nonexistent)
+++ testsuite/g++.dg/cpp1z/class-deduction46.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/80449
+// { dg-options -std=c++17 }
+
+template<class S> struct C;
+template<> struct C<int> { C(int, int) {} };
+auto k = C{0, 0}; // { dg-error "cannot deduce" }
More information about the Gcc-patches
mailing list