From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97FDB3858C98; Mon, 12 Feb 2024 18:36:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97FDB3858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707763012; bh=OYE1ZFp0q8xL5vCaS+llsZNpnov/moVUOd0Vq7QqcP0=; h=From:To:Subject:Date:From; b=YRmfbpHR/21P98cHvisb5RFW2n7Nywa+GpR5K1fEFCnURK45uKTRQGFYXryG6vwb4 qh7GGgL0Rtkm1uiRt4cr6RgabwysLqzWx8uAOxf2rwAoXpuQsJ3bod/QmMSSJ5wDiC AzcxfoQDzV+eOoeqBnDMFee4ifTMJ+DUCwvApCtw= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113892] New: Missing temporary in assignment for array-valued function referencing host-associated array Date: Mon, 12 Feb 2024 18:36:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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=3D113892 Bug ID: 113892 Summary: Missing temporary in assignment for array-valued function referencing host-associated array Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- Created attachment 57402 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57402&action=3Dedit Testcase The attached testcase is a slightly rewritten version of the discussion at: https://fortran-lang.discourse.group/t/creating-temporary-array-when-declar= ed-in-a-module/7379 All gfortran versions print: 11 21 31 12 22 32 13 23 33 11 12 13 T F F 12 22 23 T T F 13 23 33 T T T Expected: 11 21 31 12 22 32 13 23 33 11 21 31 T T T 12 22 32 T T T 13 23 33 T T T What happens? Function create_matrix takes the host-associated array "am" and returns the TRANSPOSE(am). When assigning the result directly to "am" we get a wrong result because no temporary is created. Maybe the dependency analysis of assignments needs to take care of the possibility that a non-elemental function might access a host-associated (or USE-associated or COMMON) variable appearing on the lhs.=