This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Reuse certain cxx_eval_constant_expression results in cxx_eval_vec_init_1 (PR c++/70001)


On 03/10/2016 01:39 PM, Jakub Jelinek wrote:
+      /* Don't reuse the result of cxx_eval_constant_expression
+	 call if it isn't a constant initializer or if it requires
+	 relocations.  */

Let's phrase this positively ("Reuse the result if...").

+	  if (new_ctx.ctor != ctx->ctor)
+	    eltinit = new_ctx.ctor;
+	  for (i = 1; i < max; ++i)
+	    {
+	      idx = build_int_cst (size_type_node, i);
+	      CONSTRUCTOR_APPEND_ELT (*p, idx, eltinit);
+	    }

This is going to use the same CONSTRUCTOR for all the elements, which will lead to problems if we then store into a subobject of one of the elements and see that reflected in all the others as well. We need to unshare_expr when reusing the initializer.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]