diff mbox series

[C++] PR 84350 ("[7/8 Regression] ICE with new and auto")

Message ID 5b3d0283-a419-ef28-cf5e-336c7622e754@oracle.com
State New
Headers show
Series [C++] PR 84350 ("[7/8 Regression] ICE with new and auto") | expand

Commit Message

Paolo Carlini Feb. 14, 2018, 2:53 p.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/84350
	* g++.dg/cpp0x/auto49.C: New.

Comments

Jason Merrill Feb. 14, 2018, 3:59 p.m. UTC | #1
OK.

On Wed, Feb 14, 2018 at 9:53 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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.
>
> ////////////////
>
diff mbox series

Patch

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();
+}