GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran: [PR126964] Fold element spacing into field alignment

Fortran alignment calculations now consider the minimum alignment of a component's type, fixing issues with non-standard alignments.

This change addresses a bug where Fortran’s alignment calculations for components did not always account for the minimum required alignment of the component’s type. For example, the i386 ABI aligns real(8) to 4 bytes, leading to incorrect spacing calculations. The fix compares element length against min_align_of_type instead of just the alignment, improving accuracy for structures with non-standard component alignments. New test cases are included.

In Details

In fortran/trans-array.cc, the function gfc_span_folds_into_stride previously used align_of_type to determine spacing, which could be insufficient when a target ABI specifies a looser alignment than the type requires (e.g., i386 ABI aligning real(8) to 4 bytes). This commit changes the comparison to use min_align_of_type instead, ensuring that the spacing correctly accounts for the type's minimum alignment requirements, thereby resolving PR126964.

For Context
real(8)
A Fortran data type representing an 8-byte (64-bit) floating-point number.
i386 ABI
The Application Binary Interface for the Intel 386 architecture, defining how software components interact at the binary level, including data layout and calling conventions.
min_align_of_type
A value representing the minimum number of bytes required to align an object of a given data type according to the target's ABI.
alignment
A property of a data type that specifies the required memory address boundary for instances of that type, often for performance or hardware reasons.
field alignment
The memory spacing and positioning of members within a data structure (like a struct or record) as dictated by the target architecture and ABI.
PR126964
Bug report number 126964 in the GCC bug tracking system, related to Fortran alignment issues.
Filed Under: fortranalignmentabibugfix