Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Deuling <deuling@de.ibm.com>
To: GDB Patches <gdb-patches@sourceware.org>
Subject: Access to arrays in fortran buggy
Date: Mon, 11 Feb 2008 12:36:00 -0000	[thread overview]
Message-ID: <47B040C7.8080101@de.ibm.com> (raw)

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


             reply	other threads:[~2008-02-11 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11 12:36 Markus Deuling [this message]
2008-02-11 13:27 ` Daniel Jacobowitz
2008-02-11 13:32 ` Jan Kratochvil
2008-02-12 11:30   ` Markus Deuling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47B040C7.8080101@de.ibm.com \
    --to=deuling@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox