Re: Do loops until HUGE?
- From: Richard E Maine <nospam@xxxxxxxxxxxxx>
- Date: Fri, 05 Aug 2005 14:46:34 -0700
In article
<4PQIe.552451$cg1.405193@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"James Giles" <jamesgiles@xxxxxxxxxxxxxxxx> wrote:
> The trip count is computed in this case as:
>
> trips = huge(i) - huge(i) +10 + 1
>
> And that's 11. The compiler is free to assume that the
> value returned by HUGE(i) is the same for both calls
> without even making use of that value.
Indeed. But the compiler is also free to do a lot of other things,
some of which involve exceeding limits and thus making the program
invalid. The compiler *MAY* compute it as above, and that might even be
a preferred way. But it isn't required. Expressions that are
mathematically equivalent are allowed, even if they are computationally
different. Overflowing is a computational difference.
And regardless of how the trip count is computed, if the value of the
loop variable ends up as one that exceeds the compiler's representable
range, then the code is illegal. WWIII is unlikely as a result, but
messing up the DO loop trip count is plausible, within the allowed
things a compiler may do with such illegal code, and happens in some
actual compilers.
So I think that the end result is still
1. You can't assume this will work with all compilers. (It won't).
2. You can't use the standard to beat vendors into making it work.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- Follow-Ups:
- Re: Do loops until HUGE?
- From: James Giles
- Re: Do loops until HUGE?
- References:
- Do loops until HUGE?
- From: Thomas Koenig
- Re: Do loops until HUGE?
- From: Rich Townsend
- Re: Do loops until HUGE?
- From: James Giles
- Do loops until HUGE?
- Prev by Date: Re: Do loops until HUGE?
- Next by Date: Re: Do loops until HUGE?
- Previous by thread: Re: Do loops until HUGE?
- Next by thread: Re: Do loops until HUGE?
- Index(es):
Relevant Pages
|