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 

DEALLOCATE

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



Joined: 05 Jul 2006
Posts: 132

PostPosted: Thu Nov 07, 2013 11:20 am    Post subject: DEALLOCATE Reply with quote

The following program allocates memory to two arrays ia and ib. It then attempts to deallocate the memory in ib, but after (admittedly confusingly) renaming it ia in the USE statement. However, it is actually ia that gets deallocated. That seems to me to be a bug.

Code:
! This program appears to deallocate the wrong array.
MODULE m1
 INTEGER, DIMENSION(:), ALLOCATABLE :: ia
 INTEGER, DIMENSION(:), ALLOCATABLE :: ib
END MODULE m1
MODULE m2
CONTAINS
 SUBROUTINE s1 ()
  USE m1, ONLY: ia
   ALLOCATE (ia(2))
 END SUBROUTINE s1
 SUBROUTINE s2 ()
  USE m1, ONLY: ib
   ALLOCATE (ib(2))
 END SUBROUTINE s2
 SUBROUTINE s3 ()
  USE m1, ONLY: ia=>ib
   DEALLOCATE (ia)
 END SUBROUTINE s3
END MODULE m2
PROGRAM p
  USE m1
  USE m2
  CALL s1 ()
  CALL s2 ()
  CALL s3 ()
  PRINT *, ALLOCATED(ia),ALLOCATED(ib)
END PROGRAM p


Last edited by simon on Mon Nov 11, 2013 8:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 521
Location: UK

PostPosted: Thu Nov 07, 2013 6:36 pm    Post subject: Reply with quote

This looks like a bug to me too.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Nov 11, 2013 11:18 am    Post subject: Reply with quote

I agree. I have logged it for investigation.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Apr 03, 2014 11:48 am    Post subject: Reply with quote

This bug has now been fixed for the next release.
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 132

PostPosted: Sat Feb 11, 2017 1:16 am    Post subject: Reply with quote

My notes indicate that this problem was fixed in version 7.10, but it seems to have resurfaced: I'm using version 8.05. I don't know whether the problem occurred in 7.20 or 8.00.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Feb 11, 2017 9:43 am    Post subject: Reply with quote

I will take another look at this as soon as I can.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Feb 18, 2017 10:17 am    Post subject: Reply with quote

It turns out that this is a known regression.
The original fix has been removed because it caused a more serious problem elsewhere.

For now at least, I suggest that you avoid using a name for a local variable (ia in this case) when this name has already been used in a parent module.


Code:
SUBROUTINE s3 ()
  USE m1, ONLY: iaa=>ib
   DEALLOCATE (iaa)
 END SUBROUTINE s3
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