GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada: Enable inheritance of pragma/aspect unchecked_union

Enables derived types to inherit the `unchecked_union` pragma/aspect in Ada, ensuring consistent behavior.

This commit ensures that derived types correctly inherit the unchecked_union pragma/aspect in Ada. This means that if a parent type is declared as an unchecked_union, derived types will also inherit this property. This change maintains consistency and avoids unexpected behavior when working with derived types and unchecked unions.

In Details

The Ada compiler needs to correctly handle inheritance of properties like unchecked_union for derived types. This commit modifies sem_ch3.adb to ensure that record type derivations inherit Is_Unchecked_Union and Has_Unchecked_Union flags. Additionally, it updates exp_ch3.adb to ensure that derivations of Unchecked_Union types don't need an initialization procedure, reusing the init proc of their parent type.

For Context

In Ada, an unchecked_union allows treating the same memory location as different data types without type checking. This can be useful for low-level programming but requires careful handling. This commit ensures that when a type is declared as an unchecked_union, any types derived from it also inherit this property. This maintains consistency and prevents unexpected behavior when working with derived types, making it easier to reason about the code.

Filed Under: adainheritanceunchecked_union