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: Mark Mitchell <mark at codesourcery dot com>
- To: Giovanni Bajo <giovannibajo at libero dot it>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, Paolo Carlini <pcarlini at suse dot de>
- Date: Tue, 04 Jan 2005 23:39:13 -0800
- Subject: Re: [C++ PATCH] [PR19163] Fix attribute aligned on dependent arraytypes
- Organization: CodeSourcery, LLC
- References: <022201c4ec60$62d4b820$394e2597@bagio> <20041227225753.GC5386@redhat.com> <031101c4ecc7$b1c21470$394e2597@bagio> <41D9A1B1.3030302@codesourcery.com> <035a01c4f20d$6770aa30$7c4e2a97@bagio>
Giovanni Bajo wrote:
Mark Mitchell <mark@codesourcery.com> wrote:
Second, I'm not sure that you've dealt with RTH's question fully. In
the case that the original type is dependent, does TYPE_ALIGN (t)
have a sensible value?
If TYPE_USER_ALIGN is true, the answer is yes, and TYPE_ALIGN carries the
alignment specified by the user in the attribute. If TYPE_USER_ALIGN is no, I
do not know for sure: probably it does not carry any useful information since
the type was not layed out. But my (latest) patch only commits an action if
TYPE_USER_ALING is true.
I don't think that we'll be handling the dependent case correctly.
Consider:
template <typename T>
struct S {
T t;
} __attribute__((aligned (1)));
template struct S<double>;
I looked at this in the debugger, and TYPE_USER_ALIGN looks like its
being set for S<T>. So, I would expect that with your patch TYPE_ALIGN
would be set to 1 byte for S<double>.
As you say:
And the documentation says that the "aligned" attribute
can only increase alignment; how do we know that this constraint is
being applied?
I did not know about this constraint.
It turns out that (apparently) you don't get an error; it's just that
your alignment request is ignored.
I do not know where it is enforced for
non-tempalte type/decls in the first place, I do not see such a check in
handle_align_attribute. Probably it's deeper in the middle-end, so we should
not care in the FE.
It might be that what you say is true. If so, you need to find that
place, and/or verify that the alignment of the example above is the same
as without the alignment attribute; it should be ignored. If that works
OK, please let me know; I'll reconsider the patch.
Thanks,
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304