Version 1.5 of ais/ai-00182.txt

Unformatted version of ais/ai-00182.txt version 1.5
Other versions for file ais/ai-00182.txt

!standard 07.06 (11)          99-10-07 AI95-00182/05
!standard 07.06.01 (13)
!class binding interpretation 97-03-19
!status Corrigendum 2000 99-07-28
!status WG9 Approved 97-11-14
!status ARG Approved (subject to editorial review) 10-0-0 97-04-11
!status work item 97-03-19
!status received 97-03-19
!priority High
!difficulty Easy
!qualifier Error
!subject Extension aggregates with controlled subcomponents
!summary
For an extension_aggregate whose ancestor_part is a subtype_mark, for each controlled subcomponent of the ancestor part, either Initialize is called, or the default initial value is assigned, as appropriate.
7.6.1(13) is modified so that an anonymous object is not finalized until after it is no longer accessible via any name.
!question
Question 1:
7.6(11) says: "For an extension_aggregate whose ancestor_part is a subtype_mark, Initialize is called on all controlled subcomponents of the ancestor part".
This seems inappropriate in the case of a controlled subcomponent for which a default initial value has been given. What is the intent?
Question 2:
7.6.1(13) says: "The anonymous objects created by function calls ... are finalized no later than the end of the innermost enclosing declarative_item or statement."
This rule permits a reference to a finalized object in the case where the function call is used as a name in an object renaming declaration:
<<Start_Example>> X : Some_Controlled_Type renames Some_Function_Call;
and similarly when the function call is used as an actual parameter for a generic formal in out parameter, or when a component of the object returned by the function call is renamed.
!recommendation
(See summary.)
!wording
(See summary.)
!discussion
Question 1:
The intent is that Initialize should not be called when there is an initial value to be assigned.
Question 2:
The intent is that such renamed objects should not be finalized until they are no longer "in use".
!corrigendum 7.06(11)
Replace the paragraph:
For an extension_aggregate whose ancestor_part is a subtype_mark, Initialize is called on all controlled subcomponents of the ancestor part; if the type of the ancestor part is itself controlled, the Initialize procedure of the ancestor type is called, unless that Initialize procedure is abstract.
by:
For an extension_aggregate whose ancestor_part is a subtype_mark, for each controlled subcomponent of the ancestor part, either Initialize is called, or its initial value is assigned, as appropriate; if the type of the ancestor part is itself controlled, the Initialize procedure of the ancestor type is called, unless that Initialize procedure is abstract.
!corrigendum 7.06.01(13)
Replace the paragraph:
The anonymous objects created by function calls and by aggregates are finalized no later than the end of the innermost enclosing declarative_item or statement; if that is a compound_statement, they are finalized before starting the execution of any statement within the compound_statement.
by:
If the object_name in an object_renaming_declaration, or the actual parameter for a generic formal in out parameter in a generic_instantiation, denotes any part of an anonymous object created by a function call, the anonymous object is not finalized until after it is no longer accessible via any name. Otherwise, an anonymous object created by a function call or by an aggregate is finalized no later than the end of the innermost enclosing declarative_item or statement; if that is a compound_statement, the object is finalized before starting the execution of any statement within the compound_statement.
!ACATS test
Create a C-Test that checks check that the obvious semantics are followed (i.e. no Initialize call for default initialized components). It should also check that renamed function results are not finalized too soon.
!appendix

!section 7.6(11)
!subject Extension aggregates with controlled subcomponents
!reference RM95 7.6(11)
!from Pascal Leroy 97-03-10
!reference 97-15727.a Pascal Leroy 97-3-10>>
!discussion

The referenced paragraph states that: "For an extension_aggregate whose
ancestor_part is a subtype_mark, Initialize is called on all controlled
subcomponents of the ancestor part".

This seems inappropriate in the case of a controlled subcomponent for which a
default initial value has been given.  Consider the following example:

   type T1 is new Ada.Finalization.Controlled with null record;

   X : T1;

   type T2 is new Ada.Finalization.Controlled with
      record
         F : T1 := X;
      end record;

   type T3 is new T2 with null record;

   Y : T3 := (T2 with null record);

RM95 7.6(11) seems to say that Initialize is called on component F of the
extension aggregate, but it would be more sensible to assign to F the initial
value X.  That would be consistent with the treatment of objects created by
object_declarations, as specified in RM95 7.6(10).

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

!section 7.6.1(13)
!subject Renaming a controlled object returned by a function
!reference RM95 7.6.1(13)
!from Pascal Leroy 97-03-10
!reference 97-15727.b Pascal Leroy 97-3-10>>
!discussion

The referenced paragraph states that: "The anonymous objects created by
function calls ... are finalized no later than the end of the innermost
enclosing declarative_item or statement."

This rule permits a reference to a finalized object in the case where the
function call is used as a name in an object renaming declaration:

   X : Some_Controlled_Type renames Some_Function_Call;

and similarly when the function call is used as an actual parameter for a
generic formal in out parameter, or when a component of the object returned by
the function call is renamed.

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

Questions? Ask the ACAA Technical Agent