From: Adam Beneschan <adam@irvine.com>
Subject: Re: GNAT 4.4.5 order of conditional processing?
Date: Wed, 16 Nov 2011 16:00:52 -0800 (PST)
Date: 2011-11-16T16:00:52-08:00 [thread overview]
Message-ID: <5d60a8d2-b113-45c4-9096-fe3265518059@x10g2000prk.googlegroups.com> (raw)
In-Reply-To: a25b0eac-9dae-437d-b4bb-a501cf92572c@o11g2000prg.googlegroups.com
On Nov 16, 2:40 pm, Adam Beneschan <a...@irvine.com> wrote:
> For instance:
>
> subtype Index_Subtype is Integer range 1 .. 10;
> Arr : array (Index_Subtype) of Float;
> Curr_Index : Index_Subtype;
>
> if Curr_Index_Initialized and Arr(Curr_Index) < -1.0 then ...
>
> Suppose Curr_Index_Initialized is FALSE and Curr_Index has never been
> initialized to anything. The result is that if the right side is
> evaluated, Curr_Index's uninitialized value may be a value outside the
> range 1..10, and then the code will read an element of Arr that is
> outside the bounds of Arr. Big deal. That's not likely to make a
> program fail. (Unless the bit pattern it reads happens to be a
> Signaling NaN, maybe!!)
Clarification: Depending on how Curr_Index is represented (some
compilers would fit it into an 8-bit byte while others would make it
as big as an Integer), evaluating Arr(Curr_Index) could make the
program fail if Curr_Index is big enough to put the element's address
out of the program's memory space. So it's more likely to fail than I
first claimed. Keep in mind that this is just my example and I don't
know that the OP was doing any array indexing.
-- Adam
next prev parent reply other threads:[~2011-11-17 0:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 20:30 GNAT 4.4.5 order of conditional processing? awdorrin
2011-11-15 20:54 ` Niklas Holsti
2011-11-15 21:07 ` awdorrin
2011-11-15 21:23 ` Vinzent Hoefler
2011-11-15 21:49 ` awdorrin
2011-11-16 21:31 ` Gautier write-only
2011-11-16 22:40 ` Adam Beneschan
2011-11-17 0:00 ` Adam Beneschan [this message]
2011-11-15 23:08 ` Jeffrey Carter
2011-11-16 1:18 ` Adam Beneschan
2011-11-16 5:33 ` tmoran
2011-11-16 17:52 ` awdorrin
2011-11-16 20:01 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox