https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121145
Bug ID: 121145 Summary: Unnecessary runtime error: non-associated procedure pointer passed to optional argument Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: federico.perini at gmail dot com Target Milestone: --- module m abstract interface subroutine fun(x) ! just a function real, intent(in) :: x end subroutine fun end interface contains subroutine with_fun(sub) procedure(fun), optional :: sub print *, present(sub) end subroutine end module m program p use m procedure(fun), pointer :: ptr => null() call with_fun() ! no runtime error call with_fun(sub=ptr) ! runtime error if `fcheck=pointer` end The example shows that a non-associated procedure pointer, legally passed to a procedure where it is `optional`, triggers a Fortran runtime error with `fcheck=pointer`. The same does not happen when the argument is a data variable, instead of a procedure. This is a very minor thing but I believe it would be a great quality-of-life improvement (turning off pointer checks is bad, in debug builds...) I put a live example here: https://godbolt.org/z/5brn1h3Ga I find this issue on all versions of gfortran, so I may be wrong about this request, in which case, apologies and do feel free to close this issue. Thank you, Federico