From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C60E03858D28; Sun, 14 Jan 2024 10:51:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C60E03858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705229477; bh=5UE50oi9Mx4fVTYKlWv5P2dfjQL8J0nskvLFfcy5+ak=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XP+YQ3wbdMjgGUYfDJMQHSBrkubEZM9P5w/Mj+Xvqs3BXoogeVWSiPBaaKAO3tvsP mBo+u3jGvM386l7LYA5sO2JmTrxDS7sBFscNND+9a6HOO1cRgH8Xdq7oVOOekMJm/U M1js6Lc035uMzvsMvlWOQ0RWLcTANSHmzSxdy7SA= From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113377] Wrong code passing optional dummy argument to elemental procedure with optional dummy Date: Sun, 14 Jan 2024 10:51:17 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael 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: cc 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=3D113377 Mikael Morin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #1 from Mikael Morin --- (In reply to anlauf from comment #0) > The dump-tree suggests that the scalarizer sees the loop invariant j, > unconditionally dereferences it outside the loop, Note that the copy to the variable before the loop does NOT dereference the pointer. This case is explicitly supported by the scalarizer, see gfc_scalar_elemental_arg_saved_as_reference (and gfc_walk_elemental_function_args for the initialization of the can_be_null_= ref field). Normally this is sufficient to support optional dummies (there is also additional support for class wrappers in gfc_conv_procedure_call), except if value comes into play. > generates code that > unconditionally dereferences j in the invocation of two, and uses a > wrong interface: These are the topics to investigate. I suppose we need to duplicate (or factor) the code for optional, value dum= mies that was added for non-elemental procedures in gfc_conv_procedure_call.=