https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93956
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Thomas Kथà¤nig <tkoe...@gcc.gnu.org>: https://gcc.gnu.org/g:2a732dbdfcc0a3bc2b4bdb5387fffa193fea6df6 commit r9-8541-g2a732dbdfcc0a3bc2b4bdb5387fffa193fea6df6 Author: Thomas König <tkoe...@gcc.gnu.org> Date: Fri Apr 24 08:22:48 2020 +0200 Fix PR 93956, wrong pointer when returned via function. Backport from trunk. This one took a bit of detective work. When array pointers point to components of derived types, we currently set the span field and then create an array temporary when we pass the array pointer to a procedure as a non-pointer or non-target argument. (This is inefficient, but that's for another release). Now, the compiler detected this case when there was a direct assignment like p => a%b, but not when p was returned either as a function result or via an argument. This patch fixes that. 2020-04-24 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/93956 * expr.c (gfc_check_pointer_assign): Also set subref_array_pointer when a function returns a pointer. * interface.c (gfc_set_subref_array_pointer_arg): New function. (gfc_procedure_use): Call it. 2020-04-24 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/93956 * gfortran.dg/pointer_assign_13.f90: New test.