Stand-alone objects (GNAT Reference Manual)

#### 17.3.5.1 Stand-alone objects ¶

    Var        : access T := ...
    Var_To_Cst : access constant T := ...
    Cst        : constant access T := ...
    Cst_To_Cst : constant access constant T := ...

In this section, we will refer to a stand-alone object of an anonymous access type as an SO.

When the restriction is in effect, the “statically deeper” relationship (see RM 3.10.2(4)) does apply to the type of a SO (contrary to RM 3.10.2(19.2)) and, for the purposes of compile-time checks, the accessibility level of the type of a SO is the accessibility level of that SO. This supports many common use-cases without the employment of `Unchecked_Access` while still removing the need for dynamic checks.

This statically disallows cases that would otherwise require a dynamic accessibility check, such as

    type Ref is access all Integer;
    Ptr : Ref;
    Good : aliased Integer;

    procedure Proc is
       Bad : aliased Integer;
       Stand_Alone : access Integer;
    begin
       if <some condition> then
          Stand_Alone := Good'Access;
       else
          Stand_Alone := Bad'Access;
       end if;
       Ptr := Ref (Stand_Alone);
    end Proc;

If a No_Dynamic_Accessibility_Checks restriction is in effect, then the otherwise-legal type conversion (the right-hand side of the assignment to Ptr) becomes a violation of the RM 4.6 rule “The accessibility level of the operand type shall not be statically deeper than that of the target type …”.