[J3] Question regarding valid set of values
Malcolm Cohen
malcolm at nag-j.co.jp
Tue May 25 00:11:08 UTC 2021
I don’t quite agree with Steve here. The standard not establishing an interpretation would mean the program is not actually standard-conforming at execution time.
(I recall this example coming up some decades ago, and that it was not conforming was not controversial at that time. The language in the standard is unchanged since then.)
I will note that HUGE(0) returns the highest model number integer. It is not impossible for a processor to have bigger machine integers than HUGE(0), though I don’t know of any current such. For example, a processor that reserves a range of bit patterns for exceptional conditions or “trap representations” (to use a C-ism), would likely have machine integers greater than HUGE(0). On such a machine, the program could be conforming at runtime.
There have been a number of machines in the past though where integers used N bits of storage but not all were used in computation, or where they were represented in a floating-point format. It is rather unlikely that such machines would become popular again, but prediction is hard.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Steve Lionel via J3
Sent: Monday, May 24, 2021 10:31 PM
To: j3 at mailman.j3-fortran.org
Cc: Steve Lionel <steve at stevelionel.com>
Subject: Re: [J3] Question regarding valid set of values
On 5/24/2021 6:30 AM, Thomas König via J3 wrote:
There are a few point which might get clarified along the way.
For example, I am currently not sure if
program foo
integer :: i
do i=0,huge(i)
end do
end
is legal or not (as long as the value of i is not subsequently used).
The source is standard-conforming. However, the behavior is processor-dependent. The execution model of the DO construct, in Loop initiation (11.1.7.4.1) says, "The iteration count is established and is the value of the expression (m2 − m1 + m3)/m3, unless that value is negative, in which case the iteration count is 0." The calculation of the iteration count may (and probably does) exceed the range of the integer kind of i. That places the program in a condition where the standard does not establish a meaning (see 4.2p5).
Steve
Disclaimer
The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: 30 St. Giles, Oxford, OX1 3LE, United Kingdom. Please see our Privacy Notice <https://www.nag.co.uk/content/privacy-notice> for information on how we process personal data and for details of how to stop or limit communications from us.
This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210525/a8afb835/attachment-0001.htm>
More information about the J3
mailing list