From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 30F453858D35; Sat, 10 Jun 2023 11:45:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30F453858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686397512; bh=CC07HvWwIZsPicQk8mHrd5UCAhOmz4e7A20E+bXz2to=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F8UoMeopCbfP2eABtM6kT+P6sPwCr3Fpuin8jHIlwl0OO9eEhE6axBzt4gip7LZO1 yjHZeYOcEOYqb3JHYChx4spaJa76dhwD0ap74IkF1PddRpUgKjUYfpLvlrz6+wmGrd fUDGxqx3l2P3QBam6F76A4f2H+GyP34YVvoCEqIk= 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: Sat, 10 Jun 2023 11:45:11 +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 #12 from Mikael Morin --- (In reply to anlauf from comment #8)=20 > Enabling derived types does not work when they occur in an array construc= tor, > and the code would ICE on empty constructors of derived type. >=20 Looking at the code, I couldn't foresee where the ICE would happen, so I tr= ied it myself. I see no ICE here. diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 04b5e30b96a..4fd3fb65a54 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -2941,10 +2941,6 @@ trans_array_constructor (gfc_ss * ss, locus * where) from constructor only for meaningful shape. */ bool zero_sized =3D zero_sized_array_p (expr); - /* FIXME: constant array constructors for DT have some issues... */ - if (expr->ts.type =3D=3D BT_DERIVED || expr->ts.type =3D=3D BT_CLASS) - zero_sized =3D false; - if (!zero_sized) nelem =3D gfc_constant_array_constructor_p (c); program test implicit none type :: t integer :: c end type t integer :: m(0) integer, allocatable :: n(:) call i call i(m) call i(n) allocate (n(0)) call i(n) call i([integer::]) ! expect "optional argument present: T" call i([1]) call j([t::]) contains subroutine i(str) integer, dimension(:), optional, intent(in) :: str write(6,*) 'optional argument present:', present(str) end subroutine i subroutine j(str) type(t), dimension(:), optional, intent(in) :: str write(6,*) 'optional argument present:', present(str) end subroutine j end program=