https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84590

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
  if (TREE_CODE (init) == TARGET_EXPR)
    init = TARGET_EXPR_INITIAL (init);
  if (TREE_CODE (init) == CONSTRUCTOR)
    {
      init = cp_fully_fold (init);
      code = push_stmt_list ();
      if (split_nonconstant_init_1 (dest, init))
        init = NULL_TREE;
assumes that at least for non-vector cp_fully_fold of a CONSTRUCTOR will yield
again a CONSTRUCTOR as well, but that is generally not the case.
It could (at least in theory) result in error_mark_node, or VIEW_CONVERT_EXPR
around the CONSTRUCTOR:
      else if (TREE_CODE (r) == CONSTRUCTOR)
        r = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (r), r);
or a TARGET_EXPR around the CONSTRUCTOR:
  if (TREE_CODE (r) == CONSTRUCTOR && CLASS_TYPE_P (TREE_TYPE (r)))
    {
      if (TREE_CODE (t) == TARGET_EXPR
          && TARGET_EXPR_INITIAL (t) == r)
        return t;
      else
        {
          r = get_target_expr (r);
          TREE_CONSTANT (r) = true;
          return r;
        }
    }
or for vectors VECTOR_CST (though that hopefully works).
So do we want something along the lines of:
--- gcc/cp/typeck2.c.jj 2018-02-26 10:46:02.163316172 +0100
+++ gcc/cp/typeck2.c    2018-02-28 16:12:44.272773436 +0100
@@ -749,6 +749,16 @@ split_nonconstant_init (tree dest, tree
   if (TREE_CODE (init) == CONSTRUCTOR)
     {
       init = cp_fully_fold (init);
+      if (TREE_CODE (init) == TARGET_EXPR)
+       init = TARGET_EXPR_INITIAL (init);
+      else if (TREE_CODE (init) == VIEW_CONVERT_EXPR
+              && TREE_CODE (TREE_OPERAND (init, 0)) == CONSTRUCTOR
+              && TREE_TYPE (TREE_OPERAND (init, 0)) == TREE_TYPE (init))
+       init = TREE_OPERAND (init, 0);
+    }
+  if (TREE_CODE (init) == CONSTRUCTOR
+      || TREE_CODE (init) == VECTOR_CST)
+    {
       code = push_stmt_list ();
       if (split_nonconstant_init_1 (dest, init))
        init = NULL_TREE;

Completely unsure about anything here though.

Reply via email to