Version 1.2 of ais/ai-00330.txt

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

!standard 4.6 (05)          04-12-03 AI95-00330/02
!class binding interpretation 03-07-22
!status Amendment 200Y 04-12-03
!status ARG Approved 9-0-1 04-11-21
!status work item 03-07-22
!status received 03-04-16
!priority Low
!difficulty Medium
!qualifier Error
!subject Generic actual parameters are always value conversions
!summary
A type conversion that is an actual generic in out parameter is a value conversion.
!question
The wording in 4.6(5) refers to an "actual parameter of mode out or in out" but it does not distinguish between an "actual parameter" of a subprogram call (per 6.4.1(3)) versus a "generic actual parameter" (per 12.3(7)).
Is a type conversion used as a generic actual parameter of mode in out a view conversion or a value conversion? (A value conversion.)
!recommendation
(See summary.)
!discussion
The standard often does say "actual parameter" to mean "generic actual parameter". For examples, see 12.4(7) and 12.7(5).
If a generic actual parameter of mode in out would qualify as a view conversion, then the legality of an object name used as a generic actual parameter would differ from that used in an object renaming declaration.
Thus we confirm the behavior of the ACATS tests and tighten the wording of 4.6(5) to apply only in calls (and not instantiations or names).
!wording
Change 4.6(5) to add "in a call" in front of "as an actual parameter".
!corrigendum 4.06(05)
Replace the paragraph:
A type_conversion whose operand is the name of an object is called a view conversion if both its target type and operand type are tagged, or if it appears as an actual parameter of mode out or in out; other type_conversions are called value conversions.
by:
A type_conversion whose operand is the name of an object is called a view conversion if both its target type and operand type are tagged, or if it appears as or if it appears in a call as an actual parameter of mode out or in out; other type_conversions are called value conversions.
!ACATS test
ACATS tests BC3102A and BC3102B already test this case.
!appendix

!topic View conversion definition is ambiguous
!reference RM95-4.6(5)
!from Ivan Cvar 03-04-16
!keywords View conversion actual parameter generic

!summary
4.6(5) usage of "actual parameter" is ambiguous with "generic actual parameter"

!problem

The wording in 4.6(5) refers to an "actual parameter of mode OUT or IN OUT"
but it does not distinguish between an "actual parameter" of a subprogram
call (per 6.4.1(3)) versus a "generic actual parameter" (per 12.3(7)).

!discussion

This ambiguity is reinforced by other occurrences in the RM where the term
"actual parameter" does indeed refer to a "generic actual parameter".  For
examples, see 12.4(7) and 12.7(5), and the corrigendum has introduced a few
more such occurrences.

This ambiguity makes me wonder whether an untagged type conversion is
officially considered to be a view conversion when it occurs as a
"generic actual parameter" of a generic instantiation.  I hope not.

If a generic actual parameter of mode IN OUT would qualify as a view
conversion, then bc3102a.ada and bc3102b.ada would be wrong.
Furthermore, the legality of an object name used as a generic actual
parameter would differ from that used in an object renaming declaration.


!proposal

Change 4.6(5) to disambiguate the wording.
Perhaps: "actual parameter of a parameter association of mode OUT or IN OUT".
Or perhaps add: "(but not a generic actual parameter)".


!example

PROCEDURE BC3102A IS               -- abridged
     GENERIC
          TYPE T IS PRIVATE;
          VAR : IN OUT T;
     PACKAGE P IS END P;

     V : INTEGER := 4;

     TYPE DI IS NEW INTEGER;

     PACKAGE ZF IS NEW P (DI, DI(V));      -- ERROR (?): TYPE CONVERSION

     ILLEGAL_RENAMING : DI RENAMES DI(V);  -- ILLEGAL (and not in orig. test)
END;

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


Questions? Ask the ACAA Technical Agent