[Bug fortran/85537] New: Invalid memory reference at runtime when calling subroutine through procedure pointer
dev-zero at gentoo dot org
gcc-bugzilla@gcc.gnu.org
Thu Apr 26 11:27:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85537
Bug ID: 85537
Summary: Invalid memory reference at runtime when calling
subroutine through procedure pointer
Product: gcc
Version: 4.8.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dev-zero at gentoo dot org
Target Milestone: ---
Given the following code, the runtime generates a segfault on the same function
when called through the procedure pointer instead of a direct function call:
module m
implicit none
contains
subroutine foo()
integer :: a
abstract interface
subroutine ibar()
end subroutine
end interface
procedure(ibar), pointer :: bar_ptr => bar_impl
a = 0
call bar_impl()
call bar_ptr()
contains
subroutine bar_impl()
write (*,*) "foo"
a = a + 1
end subroutine
end subroutine
end module
program main
use m
call foo()
end program
it will generate the following output:
$ ./segfault_minimal_rep
foo
foo
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f34795e7bbd in ???
#1 0x7f34795e6e03 in ???
#2 0x7f3478b02fdf in ???
#3 0x400788 in bar_impl
at /users/tiziano/tmp/segfault_minimal_rep.f90:21
#4 0x4007c6 in __m_MOD_foo
at /users/tiziano/tmp/segfault_minimal_rep.f90:16
#5 0x4007d1 in MAIN__
at /users/tiziano/tmp/segfault_minimal_rep.f90:30
#6 0x400808 in main
at /users/tiziano/tmp/segfault_minimal_rep.f90:28
Segmentation fault (core dumped)
More information about the Gcc-bugs
mailing list