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

Ada: Correct crash with unchecked union components of formal parameters.

Fixes a compiler crash when comparing unchecked union components of formal parameters in Ada.

A compiler crash was resolved when comparing unchecked union components of formal parameters in Ada. The fix involves refining the logic that suspends rule B.3.3(23/2) during expansion of equality functions for unchecked unions. This ensures the rule is suspended only when necessary, specifically when dealing with a component of an unchecked union type subject to a per-object constraint.

In Details

The commit modifies sem_util.adb, specifically the Prefix_Is_Formal_Parameter function, which is renamed to Prefix_Is_Formal_Parameter_Of_EQ. This function now returns True only if the formal parameter is part of an equality function built for an unchecked union type. This change avoids applying the B.3.3(23/2) rule too broadly, which was causing the crash during expansion of equality functions.

For Context

Unchecked unions in Ada allow data to be interpreted as different types without explicit conversion. Formal parameters are the input values to a function. This commit fixes a bug in the Ada compiler that caused it to crash when comparing components of unchecked unions that were passed as parameters to a function. The fix ensures that the compiler correctly handles these comparisons, preventing unexpected program termination.

Filed Under: adabugfixunchecked union