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] [PR19163] Fix attribute aligned on dependent arraytypes


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;
        }
  

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