This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, Fortran] PR 58146, enable array slice compile-time bounds checking

Le 22/08/2013 23:30, Mikael Morin a écrit :
> 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?

By the way, it seems that arg1 and arg2 declarations should be removed
in gfc_dep_compare_expr.

> 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.
For what it's worth, 'end' is non-NULL in only one place and there the
gfc_ref_dimen_size result is discarded.  Thus its handling should better
be inlined or have its own function separate from gfc_ref_dimen_size.
It seems to be a lot of trouble for little gain though.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]