------- Comment #5 from burnus at gcc dot gnu dot org 2009-06-25 16:04 ------- I think I would go for option (b) of creating a new array descriptor, which is then used for copy out. The place where currently the creation of a temporary is prevented is: gfc_trans_arrayfunc_assign
If the return symbol is assumed shape, deferred shape (pointer, allocatable) or the actual is known to be contiguous (whole array, which is not an assumed-shape/deferred-shape dummy) one can continue as is, otherwise one needs to pack the arrays. (Todo: Check that no copy in happens.) At some point, we need a contiguous check - also for F2008's CONTIGUOUS attribute. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40551