public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/111952] New: Allocatable of derived type with DTIO is not deallocated going out of scope
@ 2023-10-24  8:38 federico.perini at gmail dot com
  0 siblings, 0 replies; only message in thread
From: federico.perini at gmail dot com @ 2023-10-24  8:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111952

            Bug ID: 111952
           Summary: Allocatable of derived type with DTIO is not
                    deallocated going out of scope
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

Test program: 

```
module v
   public :: with_allocatable
   type, public :: t
      real :: r
      contains
         procedure, private :: wf
         generic :: write(formatted) => wf
   end type t
   contains
   subroutine wf(this, unit, iotype, v_list, iostat, iomsg)
      class(t), intent(in) :: this
      integer, intent(in) :: unit
      character(len=*), intent(in) :: iotype
      integer, intent(in) :: v_list(:)
      integer, intent(out) :: iostat
      character(len=*), intent(inout) :: iomsg
   end subroutine wf         

   subroutine with_allocatable(n)
      integer, intent(in) :: n
      type(t), allocatable :: x(:)
      allocate(x(n))
   end subroutine with_allocatable

end module v

program test
   use v
   call with_allocatable(10)
   call with_allocatable(10) ! crash 
end program     
```

Upon the second call, the following runtime error is returned: 
```
At line 22 of file /app/example.f90
Fortran runtime error: Attempting to allocate already allocated variable 'x'
```

I believe this may be related to bug 106731. 
On Compiler Explorer (https://godbolt.org/z/d3vfdhn6n), it seems like the issue
is present also on gfortran versions prior to that fix.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-24  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24  8:38 [Bug fortran/111952] New: Allocatable of derived type with DTIO is not deallocated going out of scope federico.perini at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).