On Mon, 2009-07-27 at 15:32 +0200, Paolo Bonzini wrote: > On 07/27/2009 12:25 PM, Robert Dewar wrote: > > Laurent GUERBY wrote: > > > >>>> if Dynamic_N >= T'First and Dynamic_N > T'Last then > >>> Huh? I can't understand the first comparison. > >>> Actually Ada is not Fortran-66 and allows empty loops, no? > >> > >> Ada for loop over "A .. B" will be empty if "A > B" and we obviously > >> must not raise an exception if the loop is empty hence the first > >> comparison is equivalent to "not (T'First > Dynamic_N)" which is true > >> when the loop is not empty. > > > > GNAT does not do this kind of hoisting, though this particular case > > could be fiddled in the front end. > > I suppose though that in Ada Dynamic_N will often be a subtype of T, at > which point the hoisting is pointless because you know that the check > passes.
In most Ada code array T index type will likely be "Natural range <>" and so the type system will not give useful bounds for optimizations. Laurent