[Bug fortran/105478] New: malloc error abort when using -fstack-arrays

m.a.hulsen at tue dot nl gcc-bugzilla@gcc.gnu.org
Wed May 4 11:27:43 GMT 2022


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

            Bug ID: 105478
           Summary: malloc error abort when using -fstack-arrays
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.a.hulsen at tue dot nl
  Target Milestone: ---

The code below gives

a.out(78480,0x10ea3f600) malloc: *** error for object 0x7ff8800a8000: pointer
being freed was not allocated
a.out(78480,0x10ea3f600) malloc: *** set a breakpoint in malloc_error_break to
debug

Program received signal SIGABRT: Process abort signal.

when compiled and build with "gfortran -fstack-arrays".

Code:

module mesh_m
  implicit none
  type element_t
    integer, allocatable, dimension(:,:) :: sidvert
  end type element_t
  type geometry_t
    type(element_t) :: element
  end type geometry_t
  type mesh_t
    type(geometry_t), allocatable, dimension(:) :: curves
  end type mesh_t
contains
  subroutine copy_element_basic ( element1, element )
    type(element_t), intent(in) :: element1
    type(element_t), intent(out) :: element
  end subroutine copy_element_basic
  subroutine copy_element_array_basic ( element1, element )
    type(element_t), dimension(:), intent(in) :: element1
    type(element_t), dimension(:), intent(out) :: element
    integer :: i
    do i = 1, size(element1)
      call copy_element_basic ( element1(i), element(i) )
    end do
  end subroutine copy_element_array_basic
end module mesh_m
program bug
  use mesh_m
  type(mesh_t) :: mesh1, mesh
  allocate(mesh1%curves(4))
  allocate(mesh%curves(4))
  call copy_element_array_basic ( mesh1%curves(:)%element, &
                                  mesh%curves(:)%element )
end program bug


More information about the Gcc-bugs mailing list