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

            Bug ID: 59251
           Summary: wrong code generation with allocatable dummy argument
                    and INTENT(OUT)
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnaud02 at users dot sourceforge.net

Using the following program:

module branch_plot_results_mod
  implicit none

  type, public :: system_variable_type
     sequence
     integer :: index = -1
  end type system_variable_type

  type branch_plot_results_type
     sequence
     integer                                 :: iu_appv = 0
     type(system_variable_type), allocatable :: system_variables(:)

  end type branch_plot_results_type
contains
  subroutine  make1 ( res)
    type(branch_plot_results_type), allocatable, intent(out) :: res !
"intent(out)" causes wrong code generation
  end subroutine make1
end module branch_plot_results_mod

program testy
  use branch_plot_results_mod
  type(branch_plot_results_type), allocatable :: res1
  call make1(res1)
end program testy

gfortran 4.8.2 on Linux x86_64 produces an executable that crashes due to a
memory corruption.
valgrind reports:
==24704== Invalid free() / delete / delete[] / realloc()
==24704==    at 0x4A071A4: free (vg_replace_malloc.c:468)
==24704==    by 0x401B25: __branch_plot_results_mod_MOD_make1 (b1.f90:16)
==24704==    by 0x401BA3: MAIN__ (b1.f90:24)
==24704==    by 0x401C21: main (b1.f90:22)
==24704==  Address 0xffefffaa0 is on thread 1's stack

This is related to the use of the INTENT(OUT). This report is a possible
duplicate of PR56218 although the program above does not use any OOP feature.

Reply via email to