replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Debugger displays garbage for local array
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Debugger displays garbage for local array

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Wed Dec 10, 2008 12:24 pm    Post subject: Debugger displays garbage for local array Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Wed Dec 10, 2008 2:54 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Thu Dec 11, 2008 12:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Thu Dec 11, 2008 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group