Simpler Accessibility Model (GNAT Reference Manual) (original) (raw)
17.3.4 Simpler Accessibility Model ¶
The goal of this feature is to simplify the accessibility rules by removing dynamic accessibility checks that are often difficult to understand and debug. The new rules eliminate the need for runtime accessibility checks by imposing more conservative legality rules when enabled via a new restriction (see RM 13.12), No_Dynamic_Accessibility_Checks, which prevents dangling reference problems at compile time.
This restriction has no effect on the user-visible behavior of a program when executed; the only effect of this restriction is to enable additional compile-time checks (described below) which ensure statically that Ada’s dynamic accessibility checks will not fail.
The feature can be activated with pragma Restrictions (No_Dynamic_Accessibility_Checks);
. As a result, additional compile-time checks are performed; these checks pertain to stand-alone objects, subprogram parameters, and function results as described below.
All of the refined rules are compatible with the [use of anonymous access types in SPARK] (‘http://docs.adacore.com/spark2014-docs/html/lrm/declarations-and-types.html#access-types
’).