Static universal_integer expressions must be accepted AI-00565/03 1
89-06-16 BI WA
| !standard 03.05.04 (08) 89-06-16 AI-00565/03
!standard 03.05.04 (13)
!standard 02.04 (01)
!standard 04.10 (04)
!standard 13.07.01 (02)
!standard 13.07.01 (03)
!class binding interpretation 88-05-04
| !status WG9-approved 89-06-16
!status ARG-approved 88-10-03 (reviewed)
!status ARG-approved (12-0-0) 88-06-06 (pending editorial review)
!status work-item 88-05-04
!references AI-00209, AI-00304
| !topic Static universal_integer expressions must be accepted
!summary 88-09-06
An implementation must accept a compilation unit containing an integer
literal or a static universal_integer expression whose value lies outside the
range SYSTEM.MIN_INT .. SYSTEM.MAX_INT.
!question 88-05-04
3.5.4(8) says:
Integer literals are the literals of an anonymous predefined
integer type that is called universal_integer ... .
This sentence says universal_integer is a predefined integer type. 3.5.4(13,
a note) says:
The smallest (most negative) value supported by the predefined
integer types of an implementation is the named number
SYSTEM.MIN_INT and the largest (most positive) value is
SYSTEM.MAX_INT (see 13.7).
The content of this note is substantiated by paragraphs 13.7.1(2, 3), which
say:
MIN_INT [is] the smallest (most negative) value of all predefined
integer types.
MAX_INT [is] the largest (most positive) value of all predefined
integer types.
Since universal_integer is a predefined integer type and since SYSTEM.MIN_INT
.. SYSTEM.MAX_INT defines the range of predefined integer types supported by
an implementation, can an implementation reject a compilation unit containing
an integer literal whose value exceeds SYSTEM.MAX_INT? Can a static
expression of type universal_integer be rejected if its value does not lie in
the range SYSTEM.MIN_INT .. SYSTEM.MAX_INT?
Static universal_integer expressions must be accepted AI-00565/03 2
89-06-16 BI WA
!recommendation 88-09-06
A static expression of type universal_integer cannot be rejected.
| !discussion 88-10-03
It was the intent of the language design that implementations accept programs
containing integer literals whose values exceed SYSTEM.MAX_INT. SYSTEM.MIN_
INT and SYSTEM.MAX_INT were intended to define the range of integer values
that is supported at run-time, i.e., MIN_INT and MAX_INT were intended to
define the range of values for the largest predefined integer type other than
universal_integer. AI-00304 reflects this intent by saying:
SYSTEM.MIN_INT is the smallest value of all predefined integer
types, excluding type universal_integer. SYSTEM.MAX_INT is the
largest value of all predefined integer types, excluding type
universal_integer.
Hence, the values of SYSTEM.MIN_INT and SYSTEM.MAX_INT are independent of the
range of universal_integer values an implementation supports. Thus,
implementations must not reject static expressions of type universal_integer,
and similarly, must not reject integer literals since these are also static
expressions of type universal_integer.
How difficult is it for an implementation to evaluate static universal_
integer expressions whose values lie outside the range MIN_INT .. MAX_INT,
i.e., is it an undue burden on implementations to require such evaluations?
AI-00209 says:
An implementation can refuse to evaluate a static universal_real
expression only if there are insufficient resources to evaluate
the expression exactly, e.g., if there is insufficient memory
available. Inexact results must not be delivered.
In the question and discussion of AI-00209, it was noted that static
universal_real values can occupy an arbitrary amount of space at compile time
since exact evaluation of static universal_real expressions is required.
Since the set of universal_real values includes the set of universal_integer
values, there is no reason why an implementation cannot correctly evaluate
static universal_integer expressions having values considerably outside the
range SYSTEM.MIN_INT .. SYSTEM.MAX_INT; of course, capacity limitations in
the compile time environment eventually will prevent a successful evaluation
(e.g., when no more memory is available). In short, given the requirement to
evaluate universal_real expressions exactly, an implementation similarly must
correctly evaluate a static universal_integer expression (including an
integer literal) unless it has insufficient resources to perform the
evaluation.
The position taken by this recommendation has not been strongly supported by
the test suite. One test allows compile-time rejection of a compilation unit
containing a based literal whose value exceeds SYSTEM.MAX_INT. Other tests
allow an implementation to reject static universal_integer expressions whose
signed values occupy 64 bits or more. Nonetheless, most implementations
today support the recommendation.