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

Disable a couple of static accessibility checks in dynamic cases

The Ada compiler now correctly applies accessibility rules for dynamic contexts by disabling certain static checks.

This commit modifies the Ada compiler to align with the Language Reference Manual’s rules regarding accessibility levels. Specifically, it disables some static accessibility checks when dealing with dynamic contexts, such as access discriminants and actual parameters, by passing Zero_On_Dynamic_Level to the accessibility calculation functions. This ensures the compiler accurately determines accessibility in situations where it varies at runtime.

In Details

The changes in exp_ch4.adb and sem_res.adb specifically target the handling of accessibility levels, particularly in the context of access discriminants and actual parameters. The Zero_On_Dynamic_Level flag is crucial here; it signals that the accessibility check should consider dynamic rather than static properties. This directly impacts how the compiler verifies that an access value designating an object is valid within its current scope, adhering to RM 3.10.2 rules.

For Context

In programming languages like Ada, 'accessibility' refers to whether a piece of data or a program element can be safely referenced from a particular part of the code. This is especially important for 'access types,' which are similar to pointers or references in other languages, as they allow one part of a program to indirectly refer to data stored elsewhere. The compiler constantly performs 'accessibility checks' to ensure that when you use an access type, the data it points to is still valid and hasn't been deallocated or gone out of scope. This commit adjusts how the Ada compiler performs these checks when the accessibility of data is determined at runtime (dynamic) rather than solely during compilation (static), bringing it in line with the language's specifications to prevent potential runtime errors.

Filed Under: adacompilersemanticsaccessibility