From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 804C83858C5E; Mon, 10 Jul 2023 20:50:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 804C83858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689022210; bh=MwkZ3cTnCL2Mu28iVbERssAmi3kvTEXUGiU4uuxJWr4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Nh/Osr0H+Bm6MMILCsaVKj0HLU2Cw8TejJjJ/azih5c3mmitT6Az2Zz1DJ9HvPd/W TtAnyItTPTQObg/XojRJA2KnhddtTONqZHesspEMyzNsVYWBzWtxwFhseLOmHyz+kL ayyQ9XeK6wpwA9yjL0MiRn7l7Wh80BABzZgxzIas= 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: Mon, 10 Jul 2023 20:50:10 +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 #3 from anlauf at gcc dot gnu.org --- The apparent discrepancy between fndecl and the actual arguments in the call may be a result from the following block in gfc_conv_procedure_call after: 7390 /* Deferred length dummies pass the character length by refer= ence 7391 so that the value can be returned. */ 7392 if (parmse.string_length && fsym && fsym->ts.deferred) ... The following patch fixes the testcase and regtests ok so far: diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 7017b652d6e..8ed812bff0d 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7404,7 +7404,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * s= ym, tmp =3D parmse.string_length; if (!VAR_P (tmp) && TREE_CODE (tmp) !=3D COMPONENT_REF) tmp =3D gfc_evaluate_now (parmse.string_length, &se->pre); - parmse.string_length =3D gfc_build_addr_expr (NULL_TREE, tmp); + if (fsym->attr.allocatable || fsym->attr.pointer) + parmse.string_length =3D gfc_build_addr_expr (NULL_TREE, tm= p); + else + parmse.string_length =3D tmp; } if (e && e->expr_type =3D=3D EXPR_VARIABLE Needs more checking.=