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

Ada: Fix bogus validity failure for reverse SSO array converted to FP

Fixes an incorrect validity check for Ada arrays with reverse storage order converted to floating-point.

This commit addresses a spurious validity failure in the Ada compiler related to arrays with reverse scalar storage order that are converted to floating-point types. The compiler’s expander already has logic to handle such cases with special care, but it was not applied in this specific conversion scenario. The change ensures that the ‘Valid attribute correctly handles these conversions by introducing a predicate Is_Reverse_Storage_Order_Object to detect when a copy is necessary.

In Details

This patch corrects an issue in gcc/ada/exp_attr.adb (Expand_N_Attribute_Reference for <Attribute_Valid>) where a validity check fails erroneously for floating-point conversions of arrays with reverse scalar storage order (SSO). The expander has a general mechanism for such objects, but a specific case was missed. The fix involves calling a new predicate, Is_Reverse_Storage_Order_Object (which replaces the older In_Reverse_Storage_Order_Object), to detect when the prefix is an object with reverse storage order, triggering the necessary copy behavior for correct validity checking bef…

For Context
SSO (Scalar Storage Order)
Refers to the order in which elements of an array or record are laid out in memory. 'Reverse' means the order is reversed compared to the default, which can affect byte ordering for multi-byte elements.
floating-point
A data type used to represent real numbers, which may have fractional parts. Examples include float and double.
Ada 'Valid attribute
In Ada, an attribute that checks the validity of an expression or object. For certain types, like floating-point numbers, validity can be affected by factors like NaN (Not a Number) values.
expander
A component within the GCC compiler that transforms higher-level intermediate representations into lower-level ones, often handling complex language features and intrinsic operations.
Filed Under: adacompiler bugstorage ordertype conversion