https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118120
--- Comment #7 from anlauf at gcc dot gnu.org ---
The following patch works and might be a reasonable compromise:
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 82a2ae1f747..985a26281ad 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -5345,7 +5345,10 @@ symbols_could_alias (gfc_symbol *lsym, gfc_symbol *rsym,
bool lsym_pointer,
bool lsym_target, bool rsym_pointer, bool rsym_target)
{
/* Aliasing isn't possible if the symbols have different base types. */
- if (gfc_compare_types (&lsym->ts, &rsym->ts) == 0)
+ if (!gfc_compare_types (&lsym->ts, &rsym->ts)
+ && !(((lsym->ts.type == BT_COMPLEX && rsym->ts.type == BT_REAL)
+ || (lsym->ts.type == BT_REAL && rsym->ts.type == BT_COMPLEX))
+ && lsym->ts.kind == rsym->ts.kind))
return 0;
/* Pointers can point to other pointers and target objects. */