From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8C6283858C5F; Tue, 11 Jul 2023 18:21:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C6283858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689099718; bh=OQvXuGjzQs+ArYDYPdbiGu0tI484heGTtYiCsD2eu10=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CzIDCVsLj9k+No+sl5l8lZxaor4XgOdpgnRlDkoHe3+FZw5tYtfXwYCz385CrAaWG qVVVL93r0U7A6rhC/21nZs2iuSCKBSzE/+rhi1rZDGrsABaYRyGGyKbkOUiEeUamqk h/JWmjKjlUsM4KVCG++48ZXZVwulo5D8LZrEeyYA= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/110288] [11/12/13/14] Regression: segfault in findloc with allocatable array of allocatable characters Date: Tue, 11 Jul 2023 18:21:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110288 --- 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-leng= th. 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 =3D FL_VARIABLE; formal_arg->sym->attr.dummy =3D 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 =3D=3D BT_CHARACTER + && !(formal_arg->sym->attr.allocatable + || formal_arg->sym->attr.pointer)) + formal_arg->sym->ts.deferred =3D false; + if (formal_arg->sym->ts.type =3D=3D BT_CHARACTER) formal_arg->sym->ts.u.cl =3D gfc_new_charlen (gfc_current_ns, NULL); Regtests OK.=