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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The difference between those two is that s1.i FIELD_DECL doesn't have
DECL_PACKED set on it (a bug in the #pragma pack support?), while with packed
attribute it does.
DECL_PACKED on the FIELD_DECL in s2 is set during check_field_decls called from
check_bases_and_members from finish_struct*.
For S1, TYPE_PACKED is actually never set, and thus DECL_PACKED neither.
The reason the s2 case is rejected is that lvalue_kind returns something with
clk_packed on it, forcing a temporary.  That was added in
https://gcc.gnu.org/ml/gcc-patches/2003-07/msg01664.html
CCing the author.
Note, even in the C FE pragma pack actually doesn't cause
TYPE_PACKED/DECL_PACKED to be set, it isn't really identical to what packed
attribute does either, e.g. I believe we should only set DECL_PACKED on
FIELD_DECLs where packed attribute on the containing type or pragma pack or
-fpack-struct= etc. actually lowered the alignment over what it would normally
have.

Reply via email to