This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix alignment handling in build_cplus_array_type/cp_build_qualified_type_real (PR c++/65690)


On Wed, Apr 08, 2015 at 10:47:15AM -0400, Jason Merrill wrote:
> On 04/08/2015 06:02 AM, Jakub Jelinek wrote:
> >	(cp_build_qualified_type_real): Use check_base_type.  Build a
> >	variant and copy over even TYPE_CONTEXT and
> >	TYPE_ALIGN/TYPE_USER_ALIGN if any of those are different.
> 
> This seems wrong.  If there is an array with the same name, attributes and
> element type, it should have the same alignment; if it doesn't, that
> probably means that one of the types hasn't been laid out yet.  We don't
> want to have two variants of the same array that are distinguished only by
> whether they've been laid out, especially since later probably both will be
> laid out and the two types will be the same.

But that is how handle_aligned_attribute works, since forever (checked it
back to 3.2).  In <= 3.4.x, it used to create it using build_type_copy,
since 4.0.0 using build_variant_type_copy, but both those routines behave
the same - build a type variant which is linked in the TYPE_NEXT_VARIANT
chain, and differs from the other type in there possibly just by
TYPE_ALIGN/TYPE_USER_ALIGN.  Perhaps it should check TYPE_ALIGN only if
at least one of the two types has TYPE_USER_ALIGN set?
As for why TYPE_ATTRIBUTES are NULL, the reason for that is that
these are attributes on a typedef, so the attributes go into DECL_ATTRIBUTES
of the TYPE_DECL instead.

Anyway, the P1 regression is just about the first hunk, so if you have
issues just with the second hunk and not the first hunk (from either of the
patches), I can just comment out the tests for alignof (const T), and open
a separate PR for that for later.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]