CVS difference for ai12s/ai12-0343-1.txt
--- ai12s/ai12-0343-1.txt 2019/10/02 01:42:49 1.2
+++ ai12s/ai12-0343-1.txt 2020/01/09 04:14:41 1.3
@@ -1,4 +1,4 @@
-!standard 6.5(5.12/5) 19-09-27 AI12-0343-1/01
+!standard 6.5(5.12/5) 20-01-08 AI12-0343-1/02
!standard 6.5(8/4)
!standard 6.5(8.1/3)
!standard 6.5(21/3)
@@ -11,8 +11,15 @@
!subject Return Statement Checks
!summary
-** TBD.
+The check of 6.5(8/4) is made immediately after the return object is
+created.
+
+The checks of 6.5(8.1/3) and 6.5(21/3) are made immediately before
+an object is returned.
+The predicate of the return subtype is checked on the return object
+immediately before an object is returned.
+
!question
Suppose you have something like
@@ -34,8 +41,6 @@
!recommendation
-[Author's recommendation, without much ARG input:]
-
The check of 6.5(8/4) is made immediately after the return object is
created (that is, immediately after the semantics of 6.5(5.12/5)
for an extended return).
@@ -46,13 +51,33 @@
For an extended return statement, any predicate that applies to the
return subtype is checked immediately before an object is returned.
-(This check probably should be added to 3.2.4, near the "in out"
-by-reference check.)
!wording
-** TBD.
+Move 6.5(22/3) and the AARM note 6.5(22.a/3) in front of the existing
+6.5(8.1/3) [which will change the number of that paragraph].
+Add after the moved AARM note:
+
+ AARM Ramification: The check on the tag of the object occurs when
+ the object is created (before any sequence_of_statements); the checks
+ which follow occur after the execution of any sequence_of_statements.
+ This is implicit in the order of definition of these Dynamic Semantics.
+
+Replace the moved 6.5(22/3) with:
+
+A check is performed that the return value satisfies the predicates of the
+return subtype.
+
+ AARM Implementation Note: The subtype conversion for of the return
+ expression for a simple_return_statement performs this same check. The
+ permissions of 11.4.1 ensure that duplicate evaluation of a predicate is
+ never required, so a single evaluation of the predicate is enough in this
+ case. Similarly, if the sequence_of_statements of an
+ extended_return_statement doesn't modify the return object, the predicate
+ check that occurs when that object is created is sufficient and does not
+ need to be repeated.
+
!discussion
The issue is that the wording of 6.5(8/4) says "A check is made ..." without
@@ -122,6 +147,28 @@
this is similar to the predicate check on out/in out by-reference parameters --
there is not a natural predicate check at that location, but it seems nasty to
allow the return of objects that don't meet the indicated predicate.
+
+---
+
+We reorder the wording so that the text about the evaluation of the
+sequence_of_statements comes betweent the 6.5(8/4) check and the 6.5(8.1/3)
+check. This implicitly gives an order of evaluation of the checks, and we
+specify that explicitly by an AARM note so that no one is confused by our
+subtlety. Explicitly mentioning the order repeatedly would harm readability,
+and we'd probably want to define a term for something like "immediately before
+return" to we wouldn't need a lengthy description of the exact point of the
+check.
+
+[Author's note: The above idea was suggested by Tucker at the last ARG
+meeting; I just followed orders. If you don't like it, don't shoot the
+messenger. If you do it like it, I'll be happy to take credit for it. ;-)]
+
+We define the extra predicate check in 6.5 (and thus before the subprogram
+returns) so that a compiler can eliminate a potentially duplicate check (as a
+similar check will be required for the subtype conversion of any return
+expression). The checks mandated in 3.2.4(31/5) are done after return, which
+would make it much harder for the compiler to determine whether a check is a
+duplicate.
!ASIS
Questions? Ask the ACAA Technical Agent