https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566

--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> ---
I was thinking that
struct __attribute__((packed)) A { int i; };
should be handled like
typedef int int_unaligned __attribute__((aligned(1)));
struct A { int_unaligned i; };
but it appears that for the aligned attribute as well we ignore the attribute
when forming pointers or references. Depending on the uses, the compiler can
print things like "int_unaligned* {aka int*}" or "ignoring attributes on
template argument" etc. It seems to me that we should not drop the
alignment-reducing attribute in those cases (it is still fine to remove it when
deducing a pass-by-copy type, as in template<class T>void f(T);int_unaligned i;
f(i); which could safely deduce T=int. Return types may be more tricky when
they end up passed as invisible reference). The C/C++ standard only consider
_Alignas/alignas to increase alignment, so I don't think changes to the case
that decreases alignment would be a conformance issue.

Reply via email to