diff mbox

[C++] PR 70501, ICE in verify ctor sanity

Message ID 57067A44.2060003@acm.org
State New
Headers show

Commit Message

Nathan Sidwell April 7, 2016, 3:18 p.m. UTC
On 04/06/16 07:49, Jason Merrill wrote:

> Sure, but that also seems unnecessary; vector rvalues don't have object identity
> the way class and array rvalues do.

I attach 2 patches.

70501-2.patch fixes the ICE by treating VECTOR_TYPEs thesame as PMFs in 
cxx_eval_bare_aggregate).

70501-other.patch stops finish_compound_literal wrapping VECTOR_TYPEs in a 
TARGET_EXPR.  And also moves the comments  around, as I found them a little 
confusing.  We might want to wait until 7.0 to apply that patch, as it's not a 
regression.

For avoidance of doubt I tested the first patch both with and without the second 
patch.

ok?

nathan

Comments

Jason Merrill April 12, 2016, 3:11 p.m. UTC | #1
On 04/07/2016 11:18 AM, Nathan Sidwell wrote:
> On 04/06/16 07:49, Jason Merrill wrote:
>
>> Sure, but that also seems unnecessary; vector rvalues don't have
>> object identity
>> the way class and array rvalues do.
>
> I attach 2 patches.
>
> 70501-2.patch fixes the ICE by treating VECTOR_TYPEs thesame as PMFs in
> cxx_eval_bare_aggregate).

OK.

> 70501-other.patch stops finish_compound_literal wrapping VECTOR_TYPEs in
> a TARGET_EXPR.  And also moves the comments  around, as I found them a
> little confusing.  We might want to wait until 7.0 to apply that patch,
> as it's not a regression.

Yes, OK once stage 1 reopens.

Jason
diff mbox

Patch

2016-04-06  Nathan Sidwell  <nathan@acm.org>

	* semantics.c (finish_compound_lteral): Don't wrap VECTOR_TYPEs in a
	TARGET_EXPR.

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 234768)
+++ cp/semantics.c	(working copy)
@@ -2732,8 +2732,8 @@  finish_compound_literal (tree type, tree
   compound_literal = digest_init (type, compound_literal, complain);
   if (TREE_CODE (compound_literal) == CONSTRUCTOR)
     TREE_HAS_CONSTRUCTOR (compound_literal) = true;
-  /* Put static/constant array temporaries in static variables, but always
-     represent class temporaries with TARGET_EXPR so we elide copies.  */
+
+  /* Put static/constant array temporaries in static variables.  */
   if ((!at_function_scope_p () || CP_TYPE_CONST_P (type))
       && TREE_CODE (type) == ARRAY_TYPE
       && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
@@ -2763,8 +2763,13 @@  finish_compound_literal (tree type, tree
 	return error_mark_node;
       return decl;
     }
-  else
-    return get_target_expr_sfinae (compound_literal, complain);
+
+  /* Represent other compound literals with TARGET_EXPR so we produce
+     an lvalue, but can elide copies.  */
+  if (!VECTOR_TYPE_P (type))
+    compound_literal = get_target_expr_sfinae (compound_literal, complain);
+
+  return compound_literal;
 }
 
 /* Return the declaration for the function-name variable indicated by