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

Ada: Fix spurious range check in class-wide preconditions.

The Ada compiler no longer generates spurious range checks for out-mode scalars in dynamic class-wide preconditions.

The Ada compiler now avoids generating spurious range checks for out-mode scalars after a class-wide precondition call. This issue was specific to dynamic preconditions (as opposed to static ones). The fix involves refactoring the helper call builders to ensure consistent processing of actual parameters.

In Details

This patch addresses an issue in exp_ch6.adb where spurious range checks were generated for out-mode scalars in dynamic class-wide preconditions. The fix refactors the Build_Helper_Call function to handle both static and dynamic precondition calls in the same way, ensuring consistent processing of actuals. The key file affected is exp_ch6.adb.

For Context

Preconditions are conditions that must be met before a function or procedure is called. In Ada, preconditions can be defined for class-wide types, which apply to all types in a class hierarchy. This commit fixes a bug in the Ada compiler that caused unnecessary range checks to be generated when dynamic (runtime) preconditions were used with class-wide types, specifically for output parameters. These extra checks could lead to performance degradation or even incorrect program behavior.

Filed Under: adabugfixpreconditions