Version 1.2 of ais/ai-00316.txt

Unformatted version of ais/ai-00316.txt version 1.2
Other versions for file ais/ai-00316.txt

!standard 6.5 (18)          02-10-03 AI95-00316/01
!class ramification 02-10-03
!status Amendment 200Y 03-02-18
!status ARG Approved 8-0-0 03-02-09
!status work item 02-10-03
!status received 02-10-03
!qualifier Omission
!priority Medium
!difficulty Easy
!subject Return accessibility checks and value conversions
!summary
6.5(18) applies to any type conversion (including value conversions) that can be used as the return expression for a return-by-reference type.
!question
Consider the following generic:
generic type T10 (<>) is limited private; C10 : in out T10; package Gen is
type Nt10 is new T10;
function Input return Nt10;
end Gen;
package body Gen is
function Input return Nt10 is begin return Nt10 (C10); --Raises Program_Error? (No.) end Input; end Gen;
type R10 (D : access Integer) is limited null record; C10 : R10 (new Integer'(19));
package Inst is new Gen (T10 => R10, C10 => C10);
R10 is an untagged return-by-reference type by 6.5(14); therefore T10 and NT10 are by untagged return-by-reference types. Nt10(C10) is a value conversion by 4.6(5/1). Does 6.5(18) apply to this name? (Yes.) The name does not appear to be an "object view". If 6.5(18) does not apply, 6.5(19) does not apply either and Program_Error must be raised.
!response
This is covered by 6.2(10): Each value of a by-reference type has an associated object. For a ... type_conversion, this object is the one associated with the operand.
Since all return-by-reference types are also by-reference types (compare 6.2(4-9) with 6.5(11-16)), 6.2(10) applies to all return-by-reference expressions. Thus all such expressions have an associated object to which the accessibility check of 6.5(18) can be applied.
We add a parenthetical remark to 6.5(18) in order to make this clear.
!corrigendum 6.5(18)
Replace the paragraph:
by:
!ACATS test
This case occurs in CD10002, which provides an adequate test.
!appendix

From: Randy Brukardt
Sent: Thursday, October 3, 2002  5:22 PM

I tried a test version of the code in the question on all of the Ada compilers
I have access to. All of them (Janus/Ada 3.1.2, GNAT 3.15a, Aonix 7.2.1, and
Rational Apex 3.2.0c) ran the program without raising Program_Error. It seems
likely that real users have code like this.

Therefore, I suggest that we declare this legal by relying on 6.2(10). Any
compilers which assumes that 6.5(18) does not apply can be changed without any
significant impact on their users.

(Note that in this interpretation 6.5(19) is not needed. A more radical change
eliminates 6.5(19) completely, and combines 6.5(17 and 18). This probably
would be the better approach in a revision, but it would mean that the
ACATS test in question could be disputed until the revision was approved. I
am not in favor of that result.)

***********************************************************

Questions? Ask the ACAA Technical Agent