This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] [PR19163] Fix attribute aligned on dependent arraytypes
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Giovanni Bajo <giovannibajo at libero dot it>, gcc-patches at gcc dot gnu dot org,Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 28 Dec 2004 01:51:14 +0100
- Subject: Re: [C++ PATCH] [PR19163] Fix attribute aligned on dependent arraytypes
- References: <022201c4ec60$62d4b820$394e2597@bagio> <20041227225753.GC5386@redhat.com>
Richard Henderson wrote:
I would expect the following test to fail with this patch.
Argh :( You are right (as usual).
Then, I would suggest adding in any case also something like align4.C below.
I'm also attaching a corresponding tentative amended patch, which
regtests Ok on x86-linux (and also libstdc++-v3 only on x86_64-linux).
Thanks to everyone,
Paolo.
// { dg-do run }
// PR c++/19163: attribute aligned on dependent array types
struct A
{ typedef double type[4]; };
template<typename _Tp>
struct B
{ typedef _Tp type[4]; };
template<unsigned _Len>
struct C
{ typedef char type[_Len] __attribute__((aligned(__alignof__(double)))); };
template<bool> struct StaticAssert;
template<> struct StaticAssert<true> {};
StaticAssert<__alignof__(A::type) == __alignof__(B<double>::type)> a1;
StaticAssert<__alignof__(A::type) == __alignof__(C<4>::type)> a2;
StaticAssert<__alignof__(A::type) == __alignof__(double)> a3;
*** pt.c.~1.962.~ Thu Dec 23 20:54:08 2004
--- pt.c Tue Dec 28 00:26:57 2004
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7347,7352 ****
--- 7347,7357 ----
}
r = build_cplus_array_type (type, domain);
+ if (TYPE_USER_ALIGN (t))
+ {
+ TYPE_ALIGN (r) = TYPE_ALIGN (t);
+ TYPE_USER_ALIGN (r) = TYPE_USER_ALIGN (t);
+ }
return r;
}