comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Concerning subscript bounds checks
Date: 1996/06/21
Date: 1996-06-21T00:00:00+00:00	[thread overview]
Message-ID: <dewar.835402601@schonberg> (raw)
In-Reply-To: 4qdj3e$btf@goanna.cs.rmit.EDU.AU


Richard said

"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.
"

I suspect this judgment is based on informal reasoning ("well it is pretty
obvious to me that it can be figured out"). As always compiler optimizations,
particularly range analysis are always more complicated than they appear
from simple examples. Yes, a compiler could figure this out, but "reasonably
smart" is probably an underestimate. I would be surprised if many existing
compilers can figure even this particular one out.

P.S. GNAT has not even started to think about optimizing checks yet,
you get junk checks even in simple loops. It's something we plan
to start work on soon!





  reply	other threads:[~1996-06-21  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 [this message]
1996-06-24  0:00   ` Adam Beneschan
1996-06-24  0:00   ` Richard A. O'Keefe
1996-06-24  0:00     ` Robert Dewar
1996-06-28  0:00     ` joeuser
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-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