AI22-0160-1

!standard 4.1.6(15/3)                                    26-05-13  AI22-0160-1/02

!class Binding Interpretation 26-04-20

!status Revision-202Y  26-05-12

!status ARG Approved  9-0-1  26-05-12

!status work item 26-04-20

!status received 26-04-20

!assigned author Stephen Baird

!submitter Stephen Baird

!priority Low

!difficulty Easy

!qualifier Omission

!subject Improved variable-vs-constant indexing selection

!summary

For a prefix of an Access attribute reference, 4.1.6(15/3) is adjusted so that it does not select an illegal constant indexing interpretation instead of a legal variable indexing interpretation.

!issue

In the case of a generalized indexing that is (part of) the prefix of an Access attribute reference, 4.1.6(15/3) can result in choosing an illegal interpretation as a constant indexing in cases where a variable indexing interpretation would have been legal. Even in the case where the access type is an access-to-constant type, there is still the requirement that the attribute prefix must be aliased.

!recommendation

Change this rule to instead choose a variable indexing interpretation in such cases.

!wording

Modify 4.1.6(15/3):

!discussion

This change also applies to Unchecked_Access attribute references as a consequence of existing equivalence rules between Access and Unchecked_Access; no separate mention is required.

The failure to distinguish between access-to-constant and access-to-variable types in the wording is intentional: by leveraging existing rules about constancy, we avoid the need to introduce explicit language about aliasedness. Recall that a variable indexing (unlike a constant indexing) is always aliased.

!example

package Example is
   -- Assume X is of a container type that has both a constant indexing
   -- function (with result type Element_Type) and a variable indexing
   -- function (returning a reference type designating Element_Type);
   -- each takes an Integer index parameter.
   function Foo (Ptr : access constant Element_Type) return Boolean;
   procedure Bar (Flag : Boolean
                        := Foo (X (123)’Access); – legal? (yes.)
end Example;

!corrigendum 4.1.6(15/3)

@drepl

@xbullet{when the @fa{generalized_indexing} is used within a @fa{primary} where a @fa{name} denoting a constant is permitted.}

@dby

@xbullet{when the @fa{generalized_indexing} is used within a @fa{primary} where a @fa{name} denoting a constant is permitted; for the purposes of this rule, the @fa{prefix} of an Access attribute does not permit a constant.}

!ACATS test

An ACATS C-Test confirming that something like the example is now legal would be appropriate.

!appendix