As Dominique pointed out (and I denied initially - sorry!) this PR is essentially the same as PR87239 except that an intrinsic, rather than an extrinsic, function is involved. I have treated it in the same way but have added a slight improvement to keep scalar elemental calls outside of the scalarization loop.
Committed to trunk as r264427. Like the patch for PR87239 I think that it is worth applying to 8-branch as a quality of implementation issue. I will wait a while before applying either patch to 8-branch. Cheers Paul 2018-09-19 Paul Thomas <pa...@gcc.gnu.org> PR fortran/84109 * trans-expr.c (gfc_trans_assignment_1): The rse.pre for the assignment of deferred character intrinsic elemental function results to a realocatable lhs must not be added to the exterior block if they are array valued but must go to the loop body. 2018-09-19 Paul Thomas <pa...@gcc.gnu.org> PR fortran/84109 * gfortran.dg/elemental_function_3.f90 : New test.