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


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


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