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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase:
struct A { const char *a, *b; };
struct B { struct A c; };

void
foo (B *x)
{
  *x = { .c = { .b = "" } };
}

  *x = B { .c = { .b = "" } };
instead of
  *x = { .c = { .b = "" } };
works fine, but it is not reshape_init that adds the missing .a initializer.

I wonder if we can just do:
--- gcc/cp/decl.c.jj    2018-03-15 08:36:22.232776316 +0100
+++ gcc/cp/decl.c       2018-03-15 11:41:39.994485812 +0100
@@ -5885,8 +5885,13 @@ reshape_init_class (tree type, reshape_i
            return error_mark_node;

          if (TREE_CODE (d->cur->index) == FIELD_DECL)
-           /* We already reshaped this.  */
-           gcc_assert (d->cur->index == field);
+           {
+             /* We already reshaped this.  */
+             tree id = DECL_NAME (d->cur->index);
+             gcc_checking_assert (d->cur->index
+                                  == get_class_binding (type, id, false));
+             field = d->cur->index;
+           }
          else if (TREE_CODE (d->cur->index) == IDENTIFIER_NODE)
            field = get_class_binding (type, d->cur->index, false);
          else
or that without the gcc_checking_assert and tree id = ...;

Reply via email to