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

--- Comment #11 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
I note that SELECT TYPE differs from ASSOCIATE and SELECT RANK here:

F2023:11.1.11.2  Execution of the SELECT TYPE construct

"Execution of a SELECT TYPE construct causes evaluation of every expression
within a selector that is a variable designator, or evaluation of a
selector that is not a variable designator."

So we actually have a temporary.

Potential fix:

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 04f0c513a7d..153ec9c1a8f 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -6479,6 +6479,7 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool strict,
bool permit_element)
   /* An associate variable may point to a non-contiguous target.  */
   if (ar && ar->type == AR_FULL
       && sym->attr.associate_var && !sym->attr.contiguous
+      && !sym->attr.select_type_temporary
       && sym->assoc
       && sym->assoc->target)
     return gfc_is_simply_contiguous (sym->assoc->target, strict,

Reply via email to