[Bug target/110044] [10, 11, 12, 13, 14 Regression] #pragma pack(push, 1) may not force packing, while __attribute__((packed, aligned(1))) works
vital.had at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 1 03:38:10 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110044
--- Comment #7 from Sergey Fedorov <vital.had at gmail dot com> ---
(In reply to Iain Sandoe from comment #6)
> I'm going to test the following (which will take some time since the
> hardware is needed for testing releases too).
>
> The test for AGGREGATE_TYPE_P() could actually be changed to
> RECORD_OR_UNION_TYPE_P () - since the case that we might have an array is
> handled for non-empty structs (but we do need to guard the empty struct
> case). The problem seems to be we were ignoring that the field type could
> be packed or that there was a cap on the max alignment.
>
> If it works as expected then I will apply to the open branches (hopefully
> before 10.5 is spun).
>
> ----
>
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index 5b3b8b52e7e..e1c038da305 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -8209,7 +8209,8 @@ darwin_rs6000_special_round_type_align (tree type,
> unsigned int computed,
> type = TREE_TYPE (type);
> } while (AGGREGATE_TYPE_P (type));
>
> - if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
> + if (type != error_mark_node && ! AGGREGATE_TYPE_P (type)
> + ! TYPE_PACKED(type) && maximum_field_alignment == 0)
> align = MAX (align, TYPE_ALIGN (type));
>
> return align;
Thank you for dealing with this!
More information about the Gcc-bugs
mailing list