AI22-0060-1

!standard 11.5(8.1/2)                                    23-04-18  AI22-0060-1/03

!class binding interpretation  23-03-15

!status Corrigendum 1-2022  23-03-30

!status ARG Approved 11-0-1  23-03-30

!status work item 23-03-15

!status received 23-03-15

!priority Low

!difficulty Easy

!qualifier Clarification

!subject Interactions between defaults and check suppression

!summary

Check suppression for a use of a default_expression or default_name is determined as if the expression/name occurred explicitly at the place where it is used.

!issue

Consider this example:

package Pkg is

   package Nested1 is
      pragma Suppress (Index_Check);
      type String_Ref is access String;
      Ptr : String_Ref := … ;
      function Func
        (C : Character := Ptr.all(3)) return Boolean is (...);
   end Nested1;

   package Nested2 is
      pragma Suppress (Access_Check);
      Flag : Boolean := Nested1.Func;
   end Nested2;

end Pkg;

 

What check suppression is in effect for the evaluation of the expression “Ptr.all(3)” ? [Access checking is suppressed, index checking is not suppressed.]

!recommendation

Clarify that the check suppression that is in effect for the evaluation of a default_expression or default_name is determined by the place of the construct that evaluates the default (and not by the place of the default expression/name itself). This rule applies recursively in the case of a default expression/name that itself includes, for example, a call with a defaulted parameter.

!wording

Add after 11.5(8.1/2):

In the case of evaluating a default_expression or default_name, the applicable check suppression is determined by the place where the evaluation occurs [redundant:, and not by where the construct occurs.]

!discussion

The chosen rule is similar to the freezing rules for these constructs. Specifically, these constructs do not freeze until they are used.

An alternative would be to “or” the suppression permissions at the place where the default occurs and where it is used (and presumably any intermediate places in the case of a default whose evaluation evaluates other defaults). That would pretty much ensure that existing implementations would not be required to make any changes, but it seems overly complex.

!example

See !Issue.

!corrigendum 11.5(8.1/2)

@dinsa

A @fa{pragma} Unsuppress revokes the permission to omit the named check (or every check in the case of All_Checks) given by any @fa{pragma} Suppress that applies at the point of the @fa{pragma} Unsuppress. The permission is revoked for the region to which the @fa{pragma} Unsuppress applies. If there is no such permission at the point of a @fa{pragma} Unsuppress, then the @fa{pragma} has no effect. A later @fa{pragma} Suppress can renew the permission.

@dby

In the case of evaluating a @fa{default_expression} or @fa{default_name}, the applicable check suppression is determined by the place where the evaluation occurs [redundant:, and not by where the construct occurs.]

!ACATS test

We don’t write ACATS tests to test check suppression.

!appendix