AI22-0061-1

!standard 11.4.2                                    23-03-17  AI22-0061-1/01

!class binding interpretation 23-03-17

!status work item 23-03-17

!status received 23-02-21

!priority Low

!difficulty Easy

!qualifier Omission

!subject Assertion policy for duplicated expressions

!summary

A declare expression may contain an Assert pragma (AI22-0045-1). If full conformance is required between two such expressions, then the assertion is enabled or disabled depending on the Assert assertion policy that is in effect at the place of the first of the two expressions.

!issue

If we have a pair of full-conformance-required expressions (for example, a default value for a formal parameter of a subprogram that has both a declaration and a body), then different assertion policies may be in effect at the places of the two expressions. If the expression contains an Assert pragma, then which assertion policy “wins”? (The assertion policy that is in effect at the place of the first expression); and similarly what if there are more than two copies of the expression, perhaps because a subprogram also has a subprogram_body_stub?  (Same answer - the assertion policy that is in effect at the place of the first copy of the expression)

!recommendation

If we have two (or more) full-conformance-required copies of an expression, then the assertion policy that is in effect for the expression is the policy in effect at the place of the first of the copies.

!wording

Append to the Dynamic Semantics section of 11.4.2 (i.e., after paragraph 23):

If two or more expressions are required to be pairwise fully conformant then only the assertion policy in effect at the place of the first of the expressions is considered in determining the dynamic semantics of evaluating the expression.

AARM Note: An example of where this rule can make a difference is two required-to-fully-conform declare_expressions which each include an Assert pragma. In this case, the Assert assertion policy that is in effect at the place of the second expression has no effect on the evaluation of the declare_expression.

!discussion

An Assert pragma occurring within a declare_expression is the only known construct that can occur within an expression and that also has dynamic semantics which are impacted by the assertion policy that is in effect at the place of the construct. In any case where full conformance of two expressions is required, the assertion policy in effect at the place of the second expression is ignored.

!example

declare
   pragma Assertion_Policy (Check)
   procedure Proc (X : T := (declare pragma Assert (...); begin …));

   pragma Assertion_Policy (Ignore);
   procedure Proc (X : T := (declare pragma Assert (...); begin …)) is
   begin
      ...;
   end;
begin
   Proc; -- the assertion is checked
end Example;

!ACATS test

An executable test based on the example would be appropriate.

!appendix