Problem with array dereferencing during using gdb with gfortran code
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Problem with array dereferencing during using gdb with gfortran code         


Author: beppo_anmeldung
Date: Sep 17, 2008 15:51

Hello,

I use the gfortran compiler and gdb for debugging. I want to check
arrays in subroutins like in the following example:

$ cat array.f90
program Test
call sub(5)
contains

subroutine sub(n)
integer, intent(in) :: n
integer, dimension(n) :: A
integer :: i

do i = 1, n
A(i) = i
end do
print *, A

end subroutine
end program
Show full article (1.59Kb)
2 Comments
Re: Problem with array dereferencing during using gdb with gfortran code         


Author: steven.bosscher
Date: Sep 17, 2008 23:32

On Sep 18, 12:51 am, beppo_anmeld...@gmx.de wrote:
> Hello,
>
> I use the gfortran compiler and gdb for debugging. I want to check
> arrays in subroutins like in the following example:
>
> $ cat array.f90
> program Test
>   call sub(5)
> contains
>
> subroutine sub(n)
>   integer, intent(in)   :: n
>   integer, dimension(n) :: A
>   integer               :: i
>
>   do i = 1, n
>     A(i) = i
>   end do
>   print *, A ...
Show full article (2.31Kb)
no comments
Re: Problem with array dereferencing during using gdb with gfortran code         


Author: Tobias Burnus
Date: Sep 18, 2008 00:58

On Sep 18, 8:32 am, steven.bossc...@gmail.com wrote:
>> Current language:  auto; currently fortran
>> (gdb) print A
>> $1 = (PTR TO -> ( int4 (0:-1))) 0x8050398
>> (gdb) print *A
>> $2 = ()

Using gfortran 4.4 with Intel's idb the output is:

13 print *, A
(idb) p A
$1 = {1, 2, 3, 4, 5, 50331709}
(idb) pt A
type = INTEGER(4)(6)
(idb) p n
$2 = 5

(That idb prints 6 instead of 5 elements is a (reported) bug in IDB;
gfortran sets the ubound to 5 but sets no lbound - DWARF3 mandates
that then 1 is used for Fortran, but IDB uses 0 (as e.g. for C) - and
"0:5" are 6 elements.)
Show full article (1.36Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
gdb and gfortran in 7.0?fa.freebsd.current ·