[Bug fortran/93925] New: Invalid memory reference upon call of a routine taking a procedure pointer as argument
mscfd at gmx dot net
gcc-bugzilla@gcc.gnu.org
Tue Feb 25 09:17:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93925
Bug ID: 93925
Summary: Invalid memory reference upon call of a routine taking
a procedure pointer as argument
Product: gcc
Version: 9.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mscfd at gmx dot net
Target Milestone: ---
The following code aborts with a segfault (invalid memory reference) upon call
of the apply function. This happens with gfortran 9.1.1 as well as a recent
gfortran-10.
module cs
implicit none
private
public classStar_map_ifc
public fun, apply
abstract interface
function classStar_map_ifc(x) result(y)
class(*), pointer :: y
class(*), target, intent(in) :: x
end function classStar_map_ifc
end interface
contains
function fun(x) result(y)
class(*), pointer :: y
class(*), target, intent(in) :: x
select type (x)
type is (integer)
y => x
class default
y => null()
end select
end function fun
function apply(f, x) result(y)
procedure(classStar_map_ifc) :: f
integer, intent(in) :: x
integer :: y
class(*), pointer :: p
p => f(x)
select type (p)
type is (integer)
y = p
end select
end function apply
end module cs
program classStar_map2
use cs
implicit none
integer :: x, y
procedure(classStar_map_ifc), pointer :: f
x = 123654
y = apply(fun, x)
print *, x, y
end program classStar_map2
More information about the Gcc-bugs
mailing list