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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The TYPE_USER_ALIGN (t) assert was there even before my change, but I agree
this is a latent problem not directly caused by r8-4668-g8a5ee94a082b3d48.

Here strip_typedefs gets "const d[0]" with TYPE_USER_ALIGN=0.  But the result
built by
result = build_cplus_array_type (type, t0);
is "const char[0]" with TYPE_USER_ALIGN=1.

When we strip_typedefs the element of the array "const d", we see it's a
typedef_variant_p, so we look at its DECL_ORIGINAL_TYPE, which is char, but we
need to add the const qualifier, so we call
cp_build_qualified_type -> build_qualified_type
where get_qualified_type checks to see if we already have such a type by
walking the variants list, which in this case is:

char -> c -> const char -> const char -> d -> const d

Because check_base_type only checks TYPE_ALIGN and not TYPE_USER_ALIGN, we
choose the first const char, which has TYPE_USER_ALIGN set.  If the element
type of an array has TYPE_USER_ALIGN, the array type gets it too.  Thus the
discrepancy.

Reply via email to