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

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

!standard 13.14(3/4)          15-06-17 AI05-0168-1/01
!class binding interpretation 15-06-17
!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
!summary
A generic instantiation of a generic with a body does not freeze everything before it.
!question
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 uninitended) 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 have a construct proper_body. (Unlike a generic specification, there are no separate generic bodies.) 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.)
!recommendation
(See Summary.)
!wording
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.]
!discussion
This looks like a case where the text model of generic instantiation has caused unintentional trouble.
!ASIS
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.
!appendix

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

Questions? Ask the ACAA Technical Agent