AI22-0115-1
!standard 13.9.2(3/4) 25-04-24 AI22-0115-1/05
!standard 13.9.2(12/5)
!standard 13.9.2(13/4)
!class Binding Interpretation 22-08-09
!status Amendment 1-2022 24-11-01
!status WG9 Approved 25-07-18
!status ARG Approved 15-0-0 24-10-31
!status work item 24-08-09
!status received 24-08-09
!submitter Randall Brukardt
!priority Low
!difficulty Easy
!qualifier Clarification
!subject Usage of the prefix of the Valid attribute
The evaluation of X’Valid is not considered to evaluate the prefix until after the validity check is complete.
The last sentence of Note 2 and all of Note 3 in 13.9.2 give an interpretation that explains that evaluating X’Valid does not cause a bounded error or erroneous execution from evaluating an invalid value. But these notes cannot be derived from any normative wording. They should be stated normatively.
(See !summary.)
Add after 13.9.2(3/4):
Notwithstanding what this Reference Manual says elsewhere, evaluating X’Valid does not evaluate the prefix X unless X is normal and has a valid representation. If X is Volatile, evaluating X’Valid is still considered a read of X.
AARM Reason: Evaluating the prefix X for an invalid or abnormal value would trigger a bounded error or erroneous execution, thus defeating the purpose of the attribute.
Since an implementation is not allowed to add, remove, or reorder accesses to volatile objects, we have to define X'Valid as a read so that it is implementable for most subtypes as the value of the object is required. End AARM Reason.
AARM Ramification: A “read of X” in the sense of C.6 does not imply the evaluation of X; the second sentence of the wording does not change the first. The implementation of X’Valid has to retrieve the value of X so it can be tested for validity (regardless of volatility), so all we’re doing here is making that explicit in the case of a volatile object.
Replace 13.9.2(12/5) with:
NOTE 2 Since evaluating X’Valid does not evaluate X unless X is normal and valid, it is not an error to check the validity of an object that is invalid or abnormal. Determining whether X satisfies the predicates of its nominal subtype can include an evaluation of X, but this determination is made only after it has been determined that X has a valid representation and therefore is safe to evaluate.
Delete 13.9.2(13/4) and the associated AARM "Reason".
Neither of these notes can be derived from normative rules. In particular, 4.1.4(11/5) says that evaluating an attribute_reference evaluates the prefix of the attribute_reference. No mere note can change that. Thus, we create a Notwithstanding rule for the evaluation of the prefix. Having done that, the second note no longer follows, and we have to state that normatively as well. We leave the consequences of the newly promoted rules as a Note.
A similar rule is needed for the Valid_Scalars attribute (see AI22-0101-1). The needed rule will be in that AI. We note that if X’Valid returns True, then X is considered normal afterwards, even if it was abnormal when the attribute was invoked. That’s not possible in general for composite types, so the Valid_Scalar attribute needs a more complex rule.
@dinsa
@xhang{@xterm{X'Valid}
Yields True if and only if the object denoted by X is normal, has a valid representation, and then, if the preceding conditions hold, the value of X also satisfies the predicates of the nominal subtype of X. The value of this attribute is of the predefined type Boolean.}
@dinst
Notwithstanding what this Reference Manual says elsewhere, evaluating X'Valid does not evaluate the prefix X unless X is normal and has a valid representation. If X is Volatile, evaluating X'Valid is still considered a read of X.
@drepl
@xindent{@s9{NOTE 2 @ Determining whether X is normal and has a valid representation as part of the evaluation of X'Valid is not considered to include an evaluation of X; hence, it is not an error to check the validity of an object that is invalid or abnormal. Determining whether X satisfies the predicates of its nominal subtype can include an evaluation of X, but only after it has been determined that X has a valid representation.}}
@dby
@xindent{@s9{NOTE 2 @ Since evaluating X’Valid does not evaluate X unless X is normal and valid, it is not an error to check the validity of an object that is invalid or abnormal. Determining whether X satisfies the predicates of its nominal subtype can include an evaluation of X, but this determination is made only after it has been determined that X has a valid representation and therefore is safe to evaluate.}}
@ddel
@xindent{@s9{If X is volatile, the evaluation of X'Valid is considered a read of X.}}
Separate ACATS tests are not needed for this issue; one cannot usefully test for the absence of a bounded error or erroneous execution, since doing the expected thing is always possible for those cases, and in the erroneous execution case, one would have to guess what bad thing might happen.