This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Access to arrays in fortran buggy


Hi,

I see some errors in the Fortran testsuite in gdb.fortran/subarray.exp.

In subarray.f is an integer array with 7 elements which contain 1-7. The test fails when printing the
array members. The only command that works is "print array" which gives

(gdb) p array
$1 = (1, 2, 3, 4, 5, 6, 7)

whereas this
(gdb) p array(1:2)
$2 = (2, 3)

is wrong. The correct result should have been (1,2), Fortran starts counting array members with 1 instead
of 0.

This
(gdb) p array(0:1)
$3 = (1, 2)
shouldn't be possible.

Fortran language uses exp_descriptor_standard to evaluate "p array ...".

If you for example use "p array (1:2)" GDB evaluates this expressions and sets the offset in the
corresponding "struct value" to 4 which would be correct for C language for example.

For my opinion Fortran should have its own evaluation routine for those expressions which access arrays.
If the type is not an array Fortran could fall back to the standard routines.


What do you think about this approach? I don't want to duplicate a lot of code so I'd say I try to implemenet
a fortran specific evaluate_subexp_standard which only works for arrays. If the type is not an array it would
fall back to evaluate_subexp_standard from eval.c.

Would this be a way to go? Another idea would be to add some language specific code to evaluate_subexp_standard in eval.c
but I think this belongs to language specific callbacks.


-- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com


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