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

Ada: Fix subtype constraint application in view conversions

Ensures subtype constraints are correctly applied to Ada view conversions when the operand is constrained.

This change corrects the Ada compiler’s behavior regarding subtype constraints in view conversions. When a view conversion involves an operand object that is itself constrained, the compiler now correctly ensures that the subtype constraint is applied to the converted value, maintaining type safety and adherence to Ada’s rules.

In Details

This commit modifies the Ada binder's handling of view conversions in exp_ch6.adb and sem_res.adb. It ensures that when a view conversion's operand is constrained, the Constrained attribute is correctly passed as True for extra actuals. This guarantees that the subtype constraint of the target type is enforced for the resulting object, fixing a bug where conversions to constrained subtypes were not properly constrained.

For Context
Ada
A structured, statically typed, and imperative programming language designed for large, long-lived applications where reliability and efficiency are critical.
Subtype Constraint
In Ada, a restriction applied to a type, limiting the range or values its objects can hold. For example, a subtype might constrain an integer to be between 1 and 100.
View Conversion
In Ada, a conversion between different types that represent the same underlying data but may have different interpretations or constraints, often involving type-derived subtypes.
Constrained Attribute
In Ada, an attribute related to whether a type or object is constrained (has a fixed range or size) or unconstrained.
Filed Under: adasemanticstype systemsafety