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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, on the second case I see what is going on.
The problem is that TYPE_TYPELESS_STORAGE is changed on an ARRAY_TYPE without
build_array_type* knowing about that, and that changes how the type is
ARRAY_TYPE is hashed and we no longer find it in the hash table.
This is because the array type is created first when the inner type is
incomplete, so it also doesn't have TYPE_TYPELESS_STORAGE flag, and only later
on is finalized.

So, either we never modify TYPE_TYPELESS_STORAGE on ARRAY_TYPEs after they are
created, but then when actually checking the flag we need to or those flags
like:
bool
get_typeless_storage (tree type)
{
  while (TREE_CODE (type) == ARRAY_TYPE)
    {
      if (TYPE_TYPELESS_STORAGE (type))
        return true;
      type = TREE_TYPE (type);
    }
  return TYPE_TYPELESS_STORAGE (type) != 0;
}
Or handle differently ARRAY_TYPEs with scalar vs. aggregate elements.
For !AGGREGATE_TYPE_P elements (or INTEGRAL_TYPE_P?), we'd do the hashing and
comparisons of TYPE_TYPELESS_STORAGE flag, otherwise we'd ignore that flag in
hashing and comparisons, basically treat it as - this will be inherited from
the element type.

Reply via email to