From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABF823858D38; Mon, 12 Jun 2023 07:39:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABF823858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686555546; bh=cnKq5TJhbmcIhNGyh2PtkrtFqwb9ozmZ/iS0kM6f3sE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nHngK44gnE9opbpmYZmqCZjU3v5M7yxBBT5uB83RHrVI67CugFqQwUH+bmer2LwlJ Goe0v/jsa0qmRY5bIo0txt/0BMyYR1jQt6N5vLcqaJZbNLLf/BfVKSe6+Txr/hgCoV IYXOeGoCSxi2qeCBLZ0eeqtz0S9LWLQ72atnYMf0= From: "mikael 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 07:39:06 +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: mikael 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 #22 from Mikael Morin --- (In reply to anlauf from comment #20) > (In reply to Mikael Morin from comment #18) > > Created attachment 55300 [details] > > Alternative patch v2 >=20 > This patch fails for me on several occasions including the testsuite. Obviously the stack shouldn't be used if the array can grow dynamically (dynamic =3D=3D true). So the patch could be simplified further: diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 1c7ea900ea1..cc1dddbeb33 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -1117,7 +1117,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, desc =3D info->descriptor; info->offset =3D gfc_index_zero_node; - if (size =3D=3D NULL_TREE || integer_zerop (size)) + if (size =3D=3D NULL_TREE) { /* A callee allocated array. */ gfc_conv_descriptor_data_set (pre, desc, null_pointer_node);=