Version 1.2 of ai12s/ai12-0385-1.txt

Unformatted version of ai12s/ai12-0385-1.txt version 1.2
Other versions for file ai12s/ai12-0385-1.txt

!standard 4.9(20)          20-06-16 AI12-0385-1/02
!class Amendment 20-06-10
!status Amendment 1-2012 20-06-16
!status ARG Approved 13-0-0 20-06-13
!status work item 20-06-10
!status received 20-06-09
!priority Low
!difficulty Easy
!subject Predefined shifts and rotates should be static
!summary
The predefined shifts and rotates are considered static functions.
!problem
The shifting and rotating functions declared in package Interfaces are not static. That prevents using them in case alternatives, named numbers, bounds of integer type declarations, and so on. These can be useful to match a foreign type or subprogram definition.
!proposal
(See Summary.)
!wording
Add after RM 4.9(20):
* a shifting or rotating function associated with a modular
type declared in package Interfaces (see B.2);
!discussion
This change is incompatible on the margins. Static expressions are illegal if they raise any predefined exceptions; that's not true of other expressions. If an expression that raises an exception is changed to be static, the program will be rejected. If the code in question will not be executed, that can be a problem.
For example:
declare Shift : constant := 4; Base : constant Interfaces.Unsigned_32 := 7; begin if Shift < 4 then return 256 / Interfaces.Shift_Right (Base, Shift); else return 1; end if; end;
If the Shift_Right call is a evaluated as a static function, this code is illegal as we have a static divide-by-zero.
We could have added an Implementation Permission in 6.8 similar to:
An implementation may allow the aspect Static on a function for which the convention is Intrinsic and the formal parameters and result types are static scalar or string subtypes, signifying that the function is a static function (see 4.9).
However, given that a static expression can be illegal while the same expression that is non-static is legal, such a permission would involve some loss of portability (especially important in code that will not be executed, as noted above) and incompatibility with previous versions of the language.
!corrigendum 4.9(20)
Insert after the paragraph:
the new paragraph:
!ASIS
No ASIS effect.
!ACATS test
An ACATS C-Test is needed to check that these functions can be used in static expressions.
!appendix

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


Questions? Ask the ACAA Technical Agent