Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Access to arrays in fortran buggy
@ 2008-02-11 12:36 Markus Deuling
  2008-02-11 13:27 ` Daniel Jacobowitz
  2008-02-11 13:32 ` Jan Kratochvil
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Deuling @ 2008-02-11 12:36 UTC (permalink / raw)
  To: GDB Patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Access to arrays in fortran buggy
  2008-02-11 12:36 Access to arrays in fortran buggy Markus Deuling
@ 2008-02-11 13:27 ` Daniel Jacobowitz
  2008-02-11 13:32 ` Jan Kratochvil
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-02-11 13:27 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches

On Mon, Feb 11, 2008 at 01:34:15PM +0100, Markus Deuling wrote:
> 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.

No, this is supposed to be handled by the lower bound field in struct
type.  The test passes for me - I suspect your compiler is not
emitting correct debug info.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Access to arrays in fortran buggy
  2008-02-11 12:36 Access to arrays in fortran buggy Markus Deuling
  2008-02-11 13:27 ` Daniel Jacobowitz
@ 2008-02-11 13:32 ` Jan Kratochvil
  2008-02-12 11:30   ` Markus Deuling
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2008-02-11 13:32 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches

On Mon, 11 Feb 2008 13:34:15 +0100, Markus Deuling wrote:
...
> (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.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244


Regards,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Access to arrays in fortran buggy
  2008-02-11 13:32 ` Jan Kratochvil
@ 2008-02-12 11:30   ` Markus Deuling
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Deuling @ 2008-02-12 11:30 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: GDB Patches, Daniel Jacobowitz

Hi,

Jan Kratochvil schrieb:
> On Mon, 11 Feb 2008 13:34:15 +0100, Markus Deuling wrote:
> ....
>> (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.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
> 

thanks for pointing me to this. I tried a g77 and now the testsuite runs fine :-)

Regards,
Markus

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-12 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11 12:36 Access to arrays in fortran buggy Markus Deuling
2008-02-11 13:27 ` Daniel Jacobowitz
2008-02-11 13:32 ` Jan Kratochvil
2008-02-12 11:30   ` Markus Deuling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox