Le 14/08/2013 23:46, Thomas Koenig a écrit : > Hello world, > > the attached patch enables more sophisticated bounds-checking on > array slices by using gfc_dep_difference to calculate extents. > The information may also be useful in other places of the > front end, I don't really know. > > There is one wrinkle (alluded to in the comments) which makes > this harder. When somebody changes the value of a variable > used in detemining the size of an array, such as > > subroutine foo(a,n) > real, dimension(n) :: a > > n = n -2 > > print *,ubound(a(n-1:)) > > we cannot compare n-1 against n and think that their difference is > one :-( > > This is why I restricted myself to expressions where all > indices are specified, e.g. in a(n+1:n+4) or none are specified, > as in a(:). > > In order for this to work on 64-bit systems, it was necessary > to look through widening integer conversions, so I added that > functionality to discard_nops. Using this function in > gfc_dep_compare_expr made this function shorter and cleaner. > > Regression-tested. OK for trunk? > This looks mostly good. The dependency.c cleanup is nice, I have yet to understand what the 'end == NULL' condition is for. I come back to you soon.
Mikael