[Bug fortran/110288] [11/12/13/14] Regression: segfault in findloc with allocatable array of allocatable characters
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 11 18:21:57 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110288
--- Comment #4 from anlauf at gcc dot gnu.org ---
The patch in comment#3 tries to fix a symptom and is wrong. The true cause
is the attempt to derive the formal argument typespec from the actual for
intrinsics. This mistreats character, as the actual might be deferred-length.
Better fix:
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 37a9e8fa0ae..18d0fde8319 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -4725,6 +4731,13 @@ gfc_copy_formal_args_intr (gfc_symbol *dest,
gfc_intrinsic_sym *src,
formal_arg->sym->attr.flavor = FL_VARIABLE;
formal_arg->sym->attr.dummy = 1;
+ /* Be careful not to treat an actual deferred-length character
+ argument wrongly as template for the formal argument. */
+ if (formal_arg->sym->ts.type == BT_CHARACTER
+ && !(formal_arg->sym->attr.allocatable
+ || formal_arg->sym->attr.pointer))
+ formal_arg->sym->ts.deferred = false;
+
if (formal_arg->sym->ts.type == BT_CHARACTER)
formal_arg->sym->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL);
Regtests OK.
More information about the Gcc-bugs
mailing list