Version 1.1 of ais/ai-00316.txt
!standard 6.5 (18) 02-10-03 AI95-00316/01
!standard C.6 (21)
!class ramification 02-10-03
!status work item 02-10-03
!status received 02-10-03
!subject Return accessibility checks and value conversions
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.
Consider the following generic:
type T10 (<>) is limited private;
C10 : in out T10;
package Gen is
type Nt10 is new T10;
function Input return Nt10;
package body Gen is
function Input return Nt10 is
return Nt10 (C10); --
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.
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.
Replace the paragraph:
- a name that denotes an object view whose accessibility level is
not deeper than that of the master that elaborated the function body; or
- a name that denotes an object view (or a value with an associated
object, see 6.2) whose accessibility level is not deeper than that of the
master that elaborated the function body; or
This case occurs in CD10002, which provides an adequate test.
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 type. 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