This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch c++]: Fix for PR/65390
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Mar 2015 20:35:03 +0100
- Subject: Re: [patch c++]: Fix for PR/65390
- Authentication-results: sourceware.org; auth=none
- References: <CAEwic4aBYYmNx3CA6uuhsVe7LnSTqP2gnGJvM9y8k=NYEOaDgg at mail dot gmail dot com> <55071BD5 dot 9020909 at redhat dot com> <CAEwic4ZHKL6X-NfWoamWCLLxCT==PNU_+C4vR=srFDUduGW85w at mail dot gmail dot com>
2015-03-16 20:22 GMT+01:00 Kai Tietz <ktietz70@googlemail.com>:
> 2015-03-16 19:07 GMT+01:00 Jason Merrill <jason@redhat.com>:
>> If there is an alignment mismatch without user intervention, there is a
>> problem, we can't just ignore it.
>>
>> Where we run into trouble is with array types where the version built
>> earlier has not been laid out yet but the new one has been. I've been
>> trying to deal with that by making sure that we lay out the original type as
>> well, but obviously that isn't working for this case. Why not?
>
> Well, TYPE_ALIGN (t) is set to 32, and it differs to TYPE_ALIGN
> (result) (value 8), and TYPE_USER_ALIGN isn't set.
>
>> I suppose we could avoid checking TYPE_ALIGN if neither TYPE_USER_ALIGN nor
>> TYPE_SIZE are set on 't', but checking TYPE_USER_ALIGN isn't enough.
>
> For t TYPE_SIZE is set, but it isn't a constant (as it is an variably
> modified type). So we could add here additional check if TYPE_SIZE is
> a integer-constant?
>
> Something like this condition you mean?
So tested following patch checking for existing TYPE_SIZE, plus if it
is a constant-value.
Index: tree.c
===================================================================
--- tree.c (Revision 221277)
+++ tree.c (Arbeitskopie)
@@ -1356,7 +1356,9 @@ strip_typedefs (tree t)
if (!result)
result = TYPE_MAIN_VARIANT (t);
if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result)
- || TYPE_ALIGN (t) != TYPE_ALIGN (result))
+ || ((TYPE_USER_ALIGN (t)
+ || (TYPE_SIZE (t) && TREE_CODE (TYPE_SIZE (t)) == INTEGER_CST))
+ && TYPE_ALIGN (t) != TYPE_ALIGN (result)))
{
gcc_assert (TYPE_USER_ALIGN (t));
if (TYPE_ALIGN (t) == TYPE_ALIGN (result))