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

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

!standard 13.14(3/4)          15-07-07 AI12-0168-1/02
!class binding interpretation 15-06-17
!status ARG Approved 9-0-0 15-06-26
!status work item 15-06-17
!status received 15-06-08
!priority Low
!difficulty Easy
!qualifier Errors
!subject Freezing of generic instantiations of generics with bodies
A generic instantiation of a generic with a body does not freeze everything before it.
A literal reading of the Standard says that a generic instantiation of a generic with a body freezes in the same way as an explicit body. This is a huge (and likely unintended) change from the behavior of Ada 95 and Ada 2005.
Specifically, 12.3(13) says that an instance is a copy of the text of the template. 12.3(14) makes it clear that each construct (which is a syntax concept) within that instance exists and is interpreted.
A generic template that has a body will contain a proper_body. (Unlike a generic specification, there is no distinct construct generic_body.) Thus the instance will also have a proper_body (as it is a copy of the text, that is the constructs of the template).
13.14(3/4) says that "a proper_body ... causes freezing of each entity and profile declared before it ...". Thus I conclude that instantiating a generic unit with a body freezes everything.
However, it was pointed out that the current wording of 13.14(3/4) dates back all of 7 months as of this writing (to the approval of AI12-0103-1). The previous wording said that a "noninstance body" causes freezing; so clearly a generic instantiation did NOT freeze everything before it until that wording change. Thus the wording change of 13.14(3/4) is wildly incompatible (if read literally), should it be fixed? (Yes.)
(See Summary.)
Modify 13.14(3/4):
The end of a declarative_part, protected_body, or a declaration of a library package or generic library package, causes freezing of each entity and profile declared within it, except for incomplete types. A {noninstance} proper_body, body_stub, or entry_body causes freezing of each entity and profile declared before it within the same declarative_part that is not an incomplete type; it only causes freezing of an incomplete type if the body is within the immediate scope of the incomplete type.
[Editor's note: AI12-0155-1 also changes this wording. Take care in merging them if both are approved.]
This looks like a case where the text model of generic instantiation has caused unintentional trouble.
No ASIS effect.
!ACATS test
There shouldn't be a need for a separate ACATS test, as we're just reverting the meaning to the original intent.


Questions? Ask the ACAA Technical Agent