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 array types


On Mon, Dec 27, 2004 at 11:06:59PM +0100, Giovanni Bajo wrote:
>   	r = build_cplus_array_type (type, domain);
> + 	TYPE_ALIGN (r) = TYPE_ALIGN (t);
> + 	TYPE_USER_ALIGN (r) = TYPE_USER_ALIGN (t);


Surely you only want to do this for TYPE_USER_ALIGN (t) == true?

Otherwise, what alignment are you going to assign if the array
element type is dependent?  What alignment is "t" going to have
that is going to apply to the new "r"?

I would expect the following test to fail with this patch.

	template<typename T>
	struct A
	{
	  typedef T Tarr[4];
	  Tarr x;
	};

	template<typename T>
	struct B
	{
	  typedef T Tarr[4] __attribute__((aligned(16)));
	  Tarr x;
	};

	A<char> a1;
	A<double> a2;

	B<char> b1;
	B<double> b2;

	int main()
	{
	  assert (__alignof__(a1) == __alignof__(char));
	  assert (__alignof__(a2) == __alignof__(double));
	  assert (__alignof__(b1) == 16);
	  assert (__alignof__(b2) == 16);
	}


r~


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