The mapper preserves packed/bit-field alignment because those paths already
emit Ada representation aspects, but it drops an otherwise ordinary C++
type's explicit alignas requirement.
For example:
structalignas(32) Aligned
{
int value;
};
The unpatched output keeps only the convention, so GNAT gives the record its
natural alignment:
type Aligned isrecord
value : aliased int;
endrecordwith Convention => C_Pass_By_Copy;
The corrected output carries the C++ alignment into the Ada view:
type Aligned isrecord
value : aliased int;
endrecordwith Convention => C_Pass_By_Copy,
Alignment =>32;
The patch keeps Pack limited to packed or bit-field layouts and emits
Alignment independently when GCC records a user-specified type alignment.
The executable regression links C++ and Ada at -O0 and -O2 and compares
sizeof, alignof, Ada Object_Size, and Ada Alignment.
Patch.
Variant gcc-13-14
Applies to 13.2.0, 14.2.0. Source flavors: linux, darwin_arm64.
The generated Ada type uses natural alignment and disagrees with C++ sizeof and alignof.
After the patch
The generated Alignment aspect makes Ada Object_Size and Alignment agree with C++ at -O0 and -O2.
Upstream issue
Pending GCC Bugzilla filing.
Upstream submission
Not yet filed or submitted upstream.
Provenance
Repository-authored GCC patch and executable regression; exact application verified locally against the pinned Darwin release identities. Pinned FSF release application is required by Linux CI.
Licensing
GCC-derived compiler hunks remain GPL-3.0-or-later. The new test is proposed for the GCC testsuite under GCC project terms.