[gfortran,patch] More detailled runtime bounds-checking messages...

FX Coudert fxcoudert@gmail.com
Thu Aug 9 23:32:00 GMT 2007


... including out-of-bounds index and array bounds!

This patch allows us to perform runtime checks with more than a  
static failure message: we can now call runtime_error_at with a  
printf-like format string and variable arguments. The front-end also  
offers variable-args functions to build these function calls, passing  
them trees. For example, if we detect that i (which is not a compile- 
time constant, but a tree) is lower than 1 and is used as substring  
index, we can do:
     gfc_trans_runtime_check (condition, &se->pre, locus, "Substring  
index (%%ld) is smaller than one", fold_convert  
(long_integer_type_node, index));
The only thing is that we need to make sure the trees passed as  
arguments have types matching the format string.

So, I used this new functionality in bounds-checking error messages  
generated through-out the front-end, as much as possible (which is  
almost everywhere). New messages now look like:

> At line 6 of file a.f90
> Fortran runtime error: Array reference out of bounds for array  
> 'ivec', upper
> bound of dimension 1 exceeded, 3 is greater than 2

So now, I'm looking for a review to get this in, and eventually  
suggestions to change the wording if deemed inappropriate.  
Bootstrapped and regtested (both with and without -fbounds-check) on  
x86_64-linux, OK to commit?

FX



:ADDPATCH fortran:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31270.ChangeLog
Type: application/octet-stream
Size: 1357 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070809/3212a522/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31270.diff
Type: application/octet-stream
Size: 19350 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070809/3212a522/attachment-0001.obj>


More information about the Fortran mailing list