Community
cancel
Showing results for 
Search instead for 
Did you mean: 
martymike
Beginner
38 Views

crash deallocating passed pointers

We want to create a structure holding strings that vary greatly in length that can be modified during program execution. So we are using deferred length pointers. However, we are running into a problem deallocating them later. Below is a greatly simplified program that demonstrates the issue. The deallocate in the main program works. The one in subroutine a crashes.


      
      character(:), pointer :: ptr1
      character(:), pointer :: ptr2
      integer ierr
      
      allocate(character(12) :: ptr1, stat = ierr)
      ptr1 = "ABCDEFGHIJKLM"
      ptr2 => ptr1
      deallocate(ptr2)
      allocate(character(12) :: ptr1, stat = ierr)
      ptr1 = "MLKJIHGFEDCBA"
      call a(ptr1)
      
      contains
      
      subroutine a(ptr)
      character(:), pointer :: ptr
      
      ptr2 => ptr
      deallocate(ptr2)
      
      end subroutine a
      end

 

0 Kudos
2 Replies
martymike
Beginner
38 Views

Forgot to mention, running IVF 15

Kevin_D_Intel
Employee
38 Views

It appears this should work when using ptr2. It also fails with the 16.0 compiler. Deallocation is successful inside the contained routine when using the dummy argument itself. I submitted this to Development.

(Internal tracking id: DPD200377888)