This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Function pointers to a nested function / contained procedure
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: gcc mailing list <gcc at gcc dot gnu dot org>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Tue, 26 Mar 2019 22:55:25 +0100
- Subject: Function pointers to a nested function / contained procedure
Hello world,
Fortran allows pointers to contained procedures (other languages
might call this nested functions), and also allows them to be
called using procedure pointers (function pointers in C). This is
permitted as long as the host instance is still active (the parent
function is still running).
Contained procedures can access variables in their host instance.
gfortran currently allows procedure pointers to contained procedures,
but the association of variables in the host instance fails (PR 85537),
so accessing such a variable (usually) results in a segfault.
At the moment, I am at a loss of how to try to fix this. Any ideas?
Is there any other language which has such a feature, so a bit of
judicious copy & paste could be applied?
Regards
Thomas