https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125998

--- Comment #6 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
(In reply to Harald Anlauf from comment #5)
> Created attachment 64866 [details]
> Untested fix
> 
> gfc_is_not_contiguous should return true on TRANSPOSE (array).

Works for me here.

I also thought about

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 04f0c513a7d..6dba193e17d 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -6556,6 +6556,11 @@ gfc_is_not_contiguous (gfc_expr *array)
   gfc_ref *ref;
   bool previous_incomplete;

+  /* For function results fall back to gfc_is_simply_contiguous.
+     E.g. intrinsic TRANSPOSE rewrites the array descriptor.  */
+  if (array->expr_type == EXPR_FUNCTION)
+    return !gfc_is_simply_contiguous (array, false, true);
+
   for (ref = array->ref; ref; ref = ref->next)
     {
       /* Array-ref shall be last ref.  */

as a slightly more "general" solution, but am unable to construct an
example where transposed dimensions occur and which can be passed to
target, contiguous dummy which can be associated with the actual.

Reply via email to