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

Antoine Lemoine <antoine.lemo...@bordeaux-inp.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |antoine.lemoine@bordeaux-in
                   |                            |p.fr

--- Comment #28 from Antoine Lemoine <antoine.lemo...@bordeaux-inp.fr> ---
I was able to reproduce the runtime error with gfortran 9.3.0 and 10.1.0 using
the following code:

program test_recursive_call                                                     
   implicit none

   type t_tree_node
      type(t_tree_node), dimension(:), allocatable :: child
   end type

   type t_tree
      type(t_tree_node), allocatable :: root
   end type

   type(t_tree), allocatable :: tree

   allocate(tree)
   allocate(tree%root)
   allocate(tree%root%child(1))
   ! If the line below is removed, the code works fine.                         
   allocate(tree%root%child(1)%child(1))
   deallocate(tree)
end program

Command line to compile the code:
gfortran -g -fcheck=recursion -o tree tree.f90

I obtain the following runtime error:

At line 1 of file tree.f90
Fortran runtime error: Recursive call to nonrecursive procedure
'__deallocate_test_recursive_call_T_tree_node'

Error termination. Backtrace:
#0  0x5623824511fb in __deallocate_test_recursive_call_T_tree_node
        at /home/****/fortran/test_gcc_ice2/tree.f90:1
#1  0x562382451302 in __deallocate_test_recursive_call_T_tree_node
        at /home/****/fortran/test_gcc_ice2/tree.f90:1
#2  0x562382451b95 in test_recursive_call
        at /home/****/fortran/test_gcc_ice2/tree.f90:18
#3  0x562382452230 in main
        at /home/****/fortran/test_gcc_ice2/tree.f90:19

It works fine without -fcheck=recursion.

Reply via email to