This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: [gfortran,patch] PR 27895, compile-time bounds checking for array section


Much improved patch for the same problem, with the same description. I also fixed the case of:
print *, a(-5:-5:n)
which will now give a warning even if we don't know the value of n.


OK for mainline and 4.1?



Attachment: compiletime_bounds_checking.ChangeLog
Description: Binary data

Attachment: compiletime_bounds_checking.diff
Description: Binary data




Attached patch corrects the compile-time bounds checking code for
array sections by properly taking care of zero-sized sections. It also
enables the front-end to check not only the first element in the
sequence specified by a given triplet, but also the last one. It does
this by adding a function compute_last_value_for_triplet.

This allows us to emit warnings for out-of-bounds access in cases we
didn't detect before, such as:
     integer a(10)
     print *, a(1:12:3)
while avoiding messages in cases such as
     integer a(10)
     print *, a(1:11:3)

The patch is regtested on i686-linux, and comes with a testcase
covering all the possible situations I could think of. OK for mainline
and 4.1?

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