View previous topic :: View next topic |
Author |
Message |
Sebastian
Joined: 20 Feb 2008 Posts: 177
|
Posted: Wed Dec 10, 2008 12:24 pm Post subject: Debugger displays garbage for local array |
|
|
Hello,
the following code compiles fine, but the debugger displays garbage for the array "ar":
Quote: | module fdmod
integer :: maxar
end module
program fdebug
use fdmod
maxar = 10
call subtest
maxar = 20
call subtest
end program
subroutine subtest
use fdmod
integer, dimension(maxar) :: ar
ar(1:maxar) = 0
ar(2) = 5
write(*,*) ar(1),ar(2),lbound(ar),ubound(ar)
end subroutine |
I'm well aware that it is not hard to work around this problem, like passing the dimensionality to the subroutine. But it occurred in a more complex scenario in some very old sources. Also I'm not fully sure if it is legal fortran code as the array dimensions are variable bound. The code runs correctly as far as I can tell, the array resides on the stack (locally allocated) so it's not "somewhere" in memory by accident.
The source compiles with e.g.
Quote: | ftn95 /full_debug /restrict_syntax /iso fdebug.f90 /link |
(ftn95 v5.21 reg) and also the intel compiler (v10) and gfortran have been checked, they compile without any complaint even when enabling all warnings.
Thanks. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Dec 10, 2008 2:54 pm Post subject: |
|
|
This appears to be a problem with the debugger (SDBG)
This simplest work-around could be
Code: | module fdmod
integer :: maxar
end module
program fdebug
use fdmod
maxar = 10
call subtest
maxar = 20
call subtest
end program
subroutine subtest
use fdmod
integer,allocatable :: ar(:)
allocate(ar(maxar))
ar = 0
ar(2) = 5
write(*,*) ar(1),ar(2),lbound(ar),ubound(ar)
end subroutine |
|
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Dec 11, 2008 12:29 am Post subject: |
|
|
Paul,
I tried the original version of SUBTEST, using Sebastian's compilation options and neither of the following statements were implemented as I stepped (F7) in SDBG.
ar(1:maxar) = 0
ar(2) = 5
How extensive is this problem ? |
|
Back to top |
|
 |
Sebastian
Joined: 20 Feb 2008 Posts: 177
|
Posted: Thu Dec 11, 2008 9:05 am Post subject: |
|
|
Quote: | and neither of the following statements were implemented as I stepped (F7) in SDBG. |
As noted above they ARE implemented, and judging the disassembly the generated code is correct. Only the debugger fails to display the content of the array correctly. |
|
Back to top |
|
 |
|