From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BCEC3858C31; Sat, 9 Dec 2023 13:27:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BCEC3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702128429; bh=TSXpkJFLc0oyJrsC270SmVcIVugofpZWP1T9isb9W40=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lVwvGwTWFNAJYiMQMOwQqEbfX6uZA6tcBxQpz0xo2oWSFBmzMiBBWhpyoS9oPEKYX EYe5vkIcZaEdZtxUB4uuh2xhejEocRu8BhQzw9fe7k+iLugbZdWpi6xDZoDcyh9V3p eTR+sra7M4R1tuehUOL4GnpteFE9inIo6gv7lrE4= From: "chilikin.k at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/110987] Segmentation fault after finalization of a temporary variable Date: Sat, 09 Dec 2023 13:27:08 +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: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: chilikin.k at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D110987 --- Comment #3 from Kirill Chilikin --- The derived type T3 has zero components but not zero length as it extends T= 1; the test does not crash after the following changes: diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index 961b0b5a573..e5d12f25e5e 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1624,7 +1624,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *deriv= ed, } else if (derived && gfc_is_finalizable (derived, NULL)) { - if (derived->attr.zero_comp && !rank) + if ((derived->components =3D=3D NULL) && !rank) { /* Any attempt to assign zero length entities, causes the gimplif= ier all manner of problems. Instead, a variable is created to act = as @@ -1685,7 +1685,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *deriv= ed, } } - if (derived && derived->attr.zero_comp) + if (derived && (derived->components =3D=3D NULL)) { /* All the conditions below break down for zero length derived types= .=20 */ tmp =3D build_call_expr_loc (input_location, final_fndecl, 3,=