comp.lang.ada
 help / color / mirror / Atom feed
From: joeuser@satcom.whit.org (joeuser)
Subject: Re: Concerning subscript bounds checks
Date: 1996/06/28
Date: 1996-06-28T00:00:00+00:00	[thread overview]
Message-ID: <4r1aep$7ga@natasha.rmii.com> (raw)
In-Reply-To: 4ql9eq$hdt@goanna.cs.rmit.EDU.AU

I think I have the right piece of text here.


        >The remaining 4 occur in this context:
        >    subtype Simplex_Range is Natural range 0 .. Point'Length;
        >    P: "array (Simplex_Range) of ..."
        >    Y: "array (Simplex_Range) of ..."
        >    X: Point;
        >    J: Simplex_Range;
        >    ...
        >    J := 0;            -- at the start, J = Simplex_Range'First
        >    for I in X'Range loop
        >       ...
        >       P(J) := ...
        >       Y(J) := ...
        >       J := J + 1;
        >    end loop;          -- at the end, J = Simplex_Range'Last
        >    P(J) := ...
        >    Y(J) := ...
        >end;

        >A reasonably smart compiler should be able to tell that these four
        >subscripts are also safe.


and this is intuitively obvious to the most casual observer?
 
I think not.

Your problem lies in the J:=J+1; statement

You would be better off to use I as your index and not J.  (and it would work 
too.)  Here is why.

What happens the first time through this loop?

I=0
J=0

BUT guess what!!!!
J:=J+1;

That means that when I=X'Last
J will become X'Last+1

This basically equates to Simplex_Range'Last+1
                 Hence-----> your constraint error

J is now out of all it's possible ranges (and the ranges for the subscripts 
for both P and Y.

Is Point a string????

I love to bitch at the compilers too, but they are never wrong.  They cannot 
be wrong because they meet their standards.  Now WE have to meet theirs.

I just hope I got this to the right person.  I don't have the original 
message and had to kind of make this up from fragments.





  parent reply	other threads:[~1996-06-28  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-21  0:00 Concerning subscript bounds checks Richard A. O'Keefe
1996-06-21  0:00 ` Robert Dewar
1996-06-24  0:00   ` Richard A. O'Keefe
1996-06-24  0:00     ` Robert Dewar
1996-06-28  0:00     ` joeuser [this message]
1996-06-28  0:00       ` Adam Beneschan
1996-07-01  0:00       ` Richard A. O'Keefe
1996-07-01  0:00         ` Robert A Duff
1996-07-02  0:00           ` Richard A. O'Keefe
1996-06-24  0:00   ` William Clodius
1996-06-27  0:00     ` Richard A. O'Keefe
1996-06-28  0:00       ` Ken Thomas
1996-06-24  0:00   ` Adam Beneschan
1996-06-25  0:00 ` William Clodius
1996-06-25  0:00 ` ++           robin
1996-06-27  0:00   ` Richard A. O'Keefe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox