From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,eac70c5fad02d925 X-Google-Attributes: gidf891f,public X-Google-Thread: 103376,eac70c5fad02d925 X-Google-Attributes: gid103376,public From: joeuser@satcom.whit.org (joeuser) Subject: Re: Concerning subscript bounds checks Date: 1996/06/28 Message-ID: <4r1aep$7ga@natasha.rmii.com>#1/1 X-Deja-AN: 162625495 references: <4qdj3e$btf@goanna.cs.rmit.EDU.AU> <4ql9eq$hdt@goanna.cs.rmit.EDU.AU> content-type: Text/Plain; charset=US-ASCII organization: Satcom keywords: subscripts mime-version: 1.0 newsgroups: comp.lang.ada,comp.lang.misc Date: 1996-06-28T00:00:00+00:00 List-Id: 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.