Version 1.1 of ai05s/ai05-0013-1.txt

Unformatted version of ai05s/ai05-0013-1.txt version 1.1
Other versions for file ai05s/ai05-0013-1.txt

!standard 7.6(9.4/2)          06-04-10 AI05-0013-1/01
!class binding interpretation 06-04-10
!status work item 06-04-10
!status received 06-04-03
!priority Medium
!difficulty Medium
!qualifier Error
!subject Coextensions considered harmful
!summary
(See recommendation.)
!question
7.6(9.4) says that "A type is said to need finalization if ... it is a limited type that has an access discriminant whose designated type needs finalization."
This rule was intended to support coextensions, which get finalized when the parent object gets finalized, and must therefore been taken into account for computing the "needs finalization" properties. However:
1 - Coextensions can exist for nonlimited types. Thus, the "limited" should be deleted from the wording.
2 - This property cannot be computed at the freezing point of the type (which is the natural place to do so), as the designated type may not be frozen yet. Indeed, there is no point during the current compilation where it can be computed if the designated type is an incomplete one from a limited view - it will never be known if complete type is controlled.
!recommendation
(TBD.)
!wording
(TBD.)
!discussion
The second question defies an obvious solution. Coextension is a run-time concept, so it cannot be used in a legality rule (which is how the definition of "needs finalization" is used). The usual solution is to assume the worst. How "worst" is the problem.
(A) The easiest solution is to presume the current wording (modulo "limited") is correct. This would imply link-time checking for the No_Nested_Finalization restriction. Such checking would be very expensive to build, because every nested use of a type with an access discriminant would have to be recorded, along with its definition, and checks would have to be made if the actual complete type does in fact "need finalization". Yuck.
(B) Another easy solution is to truly assume the worst. That is, assume that any designated type of an access discriminant might "need finalization". This would allow the "needs finalization" property to be determined at freezing time. However, this would ban most uses of types with access discriminants when the No_Nested_Finalization restriction is in use: even "acccess Integer".
(C) We could assume the worst only if the designated type is not frozen at the point of the freezing of the type with the access discriminant. This would not require "access Integer" to "need finalization". However, it would make whether or not a particular type needs finalization very dependent on the freezing rules and even the order of freezing within a particular compiler. Users would not necessarily be able to tell what is happening.
(D) We could assume the worst only for incomplete types completed elsewhere (Taft types and limited views). For types frozen in the current unit, the correct answer would be determined; for incomplete types completed elsewhere, we would have to assume that they need finalization. This means delaying the determination until the end of the containing unit in some cases; "needs finalization" could not be determined at the freezing point in general. [This seems like the best of the options to me, but it seems to be a Hobson's choice.]
(E) We could ban the use of incomplete types completed elsewhere in access discriminants. (This is the solution we used for some other incomplete problems.) This is otherwise the same as (D). But it seems incompatable, and it seems like a large hammer for a relatively unimportant problem.
(F) We could drop coextensions completely (eliminating the rule altogether, and the problem). But it seems too late to do that (even though the likelyhood of problems in practice is small). Besides, this was proposed several times during the Amendment work, and it didn't fly.
!ACATS test
An ACATS B-Test should be created to test these cases.
!appendix

From: Pascal Leroy
Date: Monday, April 3, 2006  8:04 AM

7.6(9.4) says that "A type is said to need finalization if ... it is a
limited type that has an access discriminant whose designated type needs
finalization."

This rule was intended to support coextensions, which get finalized when
the parent object gets finalized, and must therefore been taken into
account for computing the "needs finalization" properties.  However, there
are two problems with this wording:

1 - The word "limited" should be erased because coextensions can exist for
nonlimited types in Ada 2005.
2 - There is a nasty interaction with the freezing rules.  I'd like to be
able to compute the "needs finalization" property at the freezing point of
the type that has the access discriminant, but at this point the type
designated by the access discriminant may not be frozen yet (heck, it may
not even be complete if it comes from a limited view).

Comments?

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


Questions? Ask the ACAA Technical Agent