From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5BE503858D38; Mon, 12 Jun 2023 20:32:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BE503858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686601940; bh=PD/9Z8BRcM+onIGMRrZyXgbN29JU5ns5ngX95FBDDM8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CAo506lHebr+pei9oWKN3VJdSy9b5g8T64VckdxXU3aJ6gOkgjUUp0njghw3onxIZ IjHPL1aEFNppqU9WWTjcLRXUr2+KAHwHZGZ+eMbqapeEmIbZaA3fKsJO42xINfQYuB Nf8XHaEKjoV+R6GwNrPdD0VJSxC1WGTMB3kCzatc= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays Date: Mon, 12 Jun 2023 20:32:20 +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: 8.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: anlauf 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=3D86277 --- Comment #29 from anlauf at gcc dot gnu.org --- (In reply to Mikael Morin from comment #28) > (In reply to anlauf from comment #27) > > (In reply to Mikael Morin from comment #25) > > > (In reply to Mikael Morin from comment #24) > > > > (In reply to Mikael Morin from comment #23) > > > > >=20 > > > > > This regresses on pr108065.f90 (that's a few extra analyzer warni= ngs), > > > > > and on pr69955.f90 (that's one extra __builtin_malloc). > > > >=20 > > > > This removes the regressions. Not fully retested again. > > > >=20 > > > Comment #23 is probably the more correct one. > > > Comment #24 works because of the double temporary. Even if the first > > > temporary has NULL data component, the second one uses malloc > > > unconditionally to set data, and the argument is seen as present. > >=20 > > Are you sure that you haven't mixed up those two? > >=20 > > When trying with my extended testcase, and looking at the tree dump, > > I see a double temporary for the call > >=20 > > call i ([real:: y]) > >=20 > > where the data pointer to the first allocation is clobbered later. > > So I would rather go with the version from comment #24. > >=20 > Let's rephrase: > When (or rather if) we manage to remove the double temporary, we'll regre= ss > with comment #24, not with comment #23. > The reallocation remains by the way, it's only pushed one step away. > Try this for example: >=20 > call i([real:: y, y]) I do see the reallocation, but in the case of the patch in #24 it is a realloc of a NULL, which is well-defined nowadays. But I do not see a regression. On the contrary, every else seems unchanged. >=20=20 > > If you don't object, I'll package the patch with testcases and submit. >=20 > No problem, I think we are safe with the second temporary. Besides the issue with one or two temporaries, is there anything else?=