Hi,

today I spent some time on this: basing on r245826, when we started ICEing. For example I wondered if we wanted to rework the use of do_auto_deduction from build_new, and check CLASS_PLACEHOLDER_TEMPLATE (auto_node) and possibly directly call do_class_deduction when d_init stays NULL_TREE because vec_safe_length (*init) != 1 ( https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cp/init.c?r1=245826&r2=245825&pathrev=245826 ). But that would require a non-static do_class_deduction and an additional function call from build_new, not at all sure it's worth it. Thus I'm just proposing the below, restoring the old diagnostic and avoiding the ICE.


Thanks, Paolo.

////////////////

/cp
2018-02-14  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84350
        * pt.c (do_auto_deduction): Don't check the TREE_TYPE of a null
        init, early return.

/testsuite
2018-02-14  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84350
        * g++.dg/cpp0x/auto49.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 257659)
+++ cp/pt.c     (working copy)
@@ -25975,7 +25975,7 @@ do_auto_deduction (tree type, tree init, tree auto
     /* C++17 class template argument deduction.  */
     return do_class_deduction (type, tmpl, init, flags, complain);
 
-  if (TREE_TYPE (init) == NULL_TREE)
+  if (init == NULL_TREE || TREE_TYPE (init) == NULL_TREE)
     /* Nothing we can do with this, even in deduction context.  */
     return type;
 
Index: testsuite/g++.dg/cpp0x/auto49.C
===================================================================
--- testsuite/g++.dg/cpp0x/auto49.C     (nonexistent)
+++ testsuite/g++.dg/cpp0x/auto49.C     (working copy)
@@ -0,0 +1,12 @@
+// PR c++/84350
+// { dg-do compile { target c++11 } }
+
+template<typename... T> void foo(T... t)
+{
+  new auto(t...);  // { dg-error "invalid use" }
+}
+
+void bar()
+{
+  foo();
+}

Reply via email to