Out-of-bounds message (was: Re: Gfortran 4.3 projects)

François-Xavier Coudert fxcoudert@gmail.com
Wed Sep 20 11:57:00 GMT 2006


Hi Tobias,

> PS: I tried to modify the out-of-bounds run-time message (PR28494), but
> I fail to extract the boundary values from a "tree". Does someone have
> an idea how to do this?
>
> trans-array.c contrains:
>    tmp = gfc_conv_array_lbound (descriptor, n);
>    fault = fold_build2 (LT_EXPR, boolean_type_node, index, tmp);
>     asprintf (&msg, "%s for array '%s', lower bound of dimension %d
>              exceeded",
>              gfc_msg_fault, se->ss->expr->symtree->name, n+1);
> and I would like to have
>          asprintf (&msg, "%s. Subscript %d of array '%s' (value %d)"
>                   " exceeds lower bound of %d"
>                   gfc_msg_fault, n+1, se->ss->expr->symtree->name,
>                   TREE_something(index), TREE_tree something(tmp));
>
> But I fail to find the TREE_something() and whether "%d" works or
> something else has to be used.

When I wrote the original message, I first wanted to write something
like you wrote in the bugzilla PR: "Fortran runtime error: Array
reference out of bounds. Subscript 1 of array 'r'
(value 5) exceeds upper bound of 4 (in file 'array2.f90', at line 4)".
That is, I wanted to mention the value of the upper bound.

However, this is a bit harder than the current code, because the index
might not be known at compile-time (unlike the dimension), so you'd
have to create a library runtime error function that takes a
printf-like list of arguments, and you'd have to construct the call
instead of simply creating a string with the message. It's something
we can do, but it's definitely one order of magnitude harder than the
current code :)

FX



More information about the Fortran mailing list