Version 1.3 of ai12s/ai12-0137-1.txt

Unformatted version of ai12s/ai12-0137-1.txt version 1.3
Other versions for file ai12s/ai12-0137-1.txt

!standard 3.10.1(2.1/2)          15-01-20 AI05-0137-1/03
!class binding interpretation 14-10-10
!status Corrigendum 2015 14-11-17
!status ARG Approved 7-0-1 14-10-19
!status work item 14-10-10
!status received 14-08-26
!priority Low
!difficulty Medium
!qualifier Clarification
!subject Incomplete views and access to class-wide types
!summary
The rules in 3.10.1(2/2 - 2.6/3) concerning uses of access types that designate incomplete views also apply to access types that designate incomplete views of class-wide types.
!question
3.10.1(2.2-2.6) says:
Given an access type A whose designated type T is an incomplete view, a dereference of a value of type A also has this incomplete view except when:
* it occurs within the immediate scope of the completion of T, or
* it occurs within the scope of a nonlimited_with_clause that mentions a library package in whose visible part the completion of T is declared, or
* it occurs within the scope of the completion of T and T is an incomplete view declared by an incomplete_type_declaration.
In these cases, the dereference has the view of T visible at the point of the dereference.
Does this apply to an access-to-class-wide type? (Yes.) A class-wide type does not have an explicit declaration, an incomplete view, or a completion.
!recommendation
(See Summary.)
!wording
Modify 3.10.1(2.1/2): An incomplete_type_declaration declares an incomplete view of a type and its first subtype; the first subtype is unconstrained if a discriminant_part appears. If the incomplete_type_declaration includes the reserved word tagged, it declares a tagged incomplete view.{ If T denotes a tagged incomplete view, then T'Class denotes a tagged incomplete view.}[Redundant: An incomplete view of a type is a limited view of the type (see 7.5).]
!discussion
The question claims that a class-wide type does not have an incompelete view, because it doesn't have an explicit declaration, and thus neither 3.10.1(2.1/2) nor 10.1.1(12.3/3) [whichever is appropriate for the kind of incomplete view] applies to it.
This is clearly the problem, in that a class-wide type should mirror its associated specific type as closely as possible.
Indeed, there doesn't seem to be any general rule about properties of specific types being associated with the class-wide type. 3.4.1(4-5) talks about components and values. 7.5(5/3) extended limitedness. There may be others.
Thus, it appears that this property needs to be explicitly spelled out in the Standard. As such, we add a sentence in 3.10.1(2.1/2) to do that, and then all is well, as 3.10.1(2.2-2.6/3) then clearly apply.
Alternative approaches of fixing 3.10.1(2.2-2.6/3) to handle this case explicitly always ran into the fatal flaw of there being no incomplete view of T'Class to talk about. Once that is fixed, there is no need to make any changes to 3.10.1(2.2-2.6/3).
!corrigendum 3.10.1(2.1/2)
Replace the paragraph:
An incomplete_type_declaration declares an incomplete view of a type and its first subtype; the first subtype is unconstrained if a discriminant_part appears. If the incomplete_type_declaration includes the reserved word tagged, it declares a tagged incomplete view. An incomplete view of a type is a limited view of the type (see 7.5).
by:
An incomplete_type_declaration declares an incomplete view of a type and its first subtype; the first subtype is unconstrained if a discriminant_part appears. If the incomplete_type_declaration includes the reserved word tagged, it declares a tagged incomplete view. If T denotes a tagged incomplete view, then T'Class denotes a tagged incomplete view. An incomplete view of a type is a limited view of the type (see 7.5).
!ASIS
No ASIS effect.
!ACATS test
We might need a ACATS C-Test to verify that access-to-classwide types can be used as complete if the corresponding access-to-tagged can be used as complete.
!appendix

!topic 3.10.1 and class-wide types
!reference RM12 3.10.1(2.2/2-2.6/3)
!from Adam Beneschan 14-08-26
!discussion

This one just looks like a minor wording problem to me.
3.10.1(2.2-2.6) says:

-------------------------------------------------------------------------------
Given an access type A whose designated type T is an incomplete view, a
dereference of a value of type A also has this incomplete view except when:

  it occurs within the immediate scope of the completion of T, or

  it occurs within the scope of a nonlimited_with_clause that mentions a
  library package in whose visible part the completion of T is declared,

or

  it occurs within the scope of the completion of T and T is an
  incomplete view declared by an incomplete_type_declaration.
  
In these cases, the dereference has the view of T visible at the point of the
dereference. 
-------------------------------------------------------------------------------

It is not clear to me that this applies to access-to-classwide types, as written,
although it should apply.  As far as I can tell, a classwide type does not have
a declaration, an incomplete view, or a completion.  Perhaps the first sentence
should be

    Given an access type A whose designated type T is an incomplete
    view, or whose designated type is T'Class where T is an incomplete
    view, a dereference of a value of type A also has this incomplete
    view except when: ...

Maybe there's somewhere else in the RM that covers this, but I haven't found it.

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

Questions? Ask the ACAA Technical Agent