The following program causes a double free violation, when compiled and run,
the error message is:
a.out(12292) malloc: *** error for object 0x2009d0: double free
*** set a breakpoint in malloc_error_break to debug
The code is:
program main

 type :: container_t
    integer, dimension(:), allocatable :: entry
 end type container_t

 type(container_t), dimension(2) :: a1, a2
 integer :: i

 do i = 1, 2
    allocate (a1(i)%entry (1), a2(i)%entry (1))
    a1(i)%entry = 0
    a2(i)%entry = i
 end do

 print *, "array1:"
 do i = 1, 2
    print *, a1(i)%entry
 end do
 print *, "array2:"
 do i = 1, 2
    print *, a2(i)%entry
 end do

 print *, "pack array2(2) into array1:"
 a1(1:1) = pack (a2(1:2), mask = [.false., .true.])

 print *, "array1:"
 do i = 1, 2
    print *, a1(i)%entry
 end do


end program main


-- 
           Summary: function "pack" causes double free violation
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reuter at physik dot uni-freiburg dot de
 GCC build triplet: i386-32bit, MAC OS X Leopard
  GCC host triplet: i386-32bit, MAC OS X Leopard
GCC target triplet: i386-32bit, MAC OS X Leopard


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

Reply via email to