[Bug fortran/40851] New: problem with deallocation of pointers

juergen dot reuter at desy dot de gcc-bugzilla@gcc.gnu.org
Fri Jul 24 20:03:00 GMT 2009


gfortran seems to deallocate a pointer which was not allocated or need not be
allocated. The program below compiles, but when executed returns the following
error message:
a.out(8814) malloc: *** error for object 0x1fa2: Non-aligned pointer being
freed
*** set a breakpoint in malloc_error_break to debug
Bus error
(Happens for Linux x86 and x86-64 as well as MAC OS X)
The code is:
program main

  type :: string
     character,dimension(:),allocatable :: chars
  end type string

  type :: string_container
     type(string) :: string
  end type string_container

  type(string_container), pointer :: ptr

  call set_ptr (ptr)

contains

  subroutine set_ptr (ptr)
    type(string_container), pointer, intent(out) :: ptr
    ptr => null ()
  end subroutine set_ptr

end program main


-- 
           Summary: problem with deallocation of pointers
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: juergen dot reuter at desy dot de
 GCC build triplet: 4.5.0 v149701
  GCC host triplet: Linux x86. x86-64 and MAC OS X
GCC target triplet: gfortran


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40851



More information about the Gcc-bugs mailing list