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

--- Comment #5 from Jan Hubicka <hubicka at ucw dot cz> ---
> diff --git a/gcc/tree.c b/gcc/tree.c
> index 39a92464414..a39e611292a 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -5201,6 +5201,15 @@ fld_process_array_type (tree t, tree t2, hash_map<tree,
> tree> *map,
>        array = build_array_type_1 (t2, TYPE_DOMAIN (t),
>                                   TYPE_TYPELESS_STORAGE (t), false);
>        TYPE_CANONICAL (array) = TYPE_CANONICAL (t);
> +      /* Re-building the array via build_array_type_1 causes the C FE
> +         special-handling of zero-length arrays to be dropped.  So
> +        we copy back TYPE_SIZE[_UNIT] from the original type here
> +        if layout_type decided the type is incomplete.  */
> +      if (!TYPE_SIZE (array))
> +       {
> +         TYPE_SIZE (array) = TYPE_SIZE (t);
> +         TYPE_SIZE_UNIT (array) = TYPE_SIZE_UNIT (t);

Makes sense to me, here.
To get types merged, we want to build same array when structure was
originally complete or incomplete. That means we should not copy real
size of the element because it is unknown in the incomplete case.

Honza
> +       }
>        add_tree_to_fld_list (array, fld);
>      }
>    return array;
> 
> -- 
> You are receiving this mail because:
> You are the assignee for the bug.

Reply via email to