-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Labels
flangFlang issues not falling into any other categoryFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
Here is a small reproducer for a flang bug tripped by our production code. In the example, a call-back subroutine is passed to another subroutine which invokes the call-back. The salient feature which results in the segfault is that the call-back is an internal procedure that accesses a variable from its parent by host association.
module factory
abstract interface
subroutine callback
end subroutine
end interface
contains
subroutine alloc_flux_bc
integer :: n
n = 42
call iterate_list(my_cb)
contains
subroutine my_cb
print *, n ! N ACCESSED FROM PARENT BY HOST ASSOCIATION
end subroutine
end subroutine
subroutine iterate_list(cb)
procedure(callback) :: cb
call cb ! SEGFAULTS HERE
end subroutine
end module
program main
use factory
call alloc_flux_bc
end program
With the main branch code (as of today), running the compiled code segfaults; the expected output is simply "42". NAG, gfortran, and Intel oneAPI all compile and run this example without error.
Metadata
Metadata
Assignees
Labels
flangFlang issues not falling into any other categoryFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!