From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4907385842D; Thu, 20 Apr 2023 16:29:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4907385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682008149; bh=NEcBSJNtLMrlyV6tMCIoXjLU30WeK0ACuggDpf7DDMc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=olmQd7zQ/lWKAKG/MhWoSll3J6fbjmPOqI0da0y0cA1Au4WOov+0ZlsdE0UFjJi8G R+hq/FZFLG1/ldK+3X+Q+R1KBcQeJJFRLKsAmkX1i6cy83jMc3yapqYsSfkMNpQb2E etHevwWeQawv7a/qiP09mMiDdTer3pAHQrtzhzGM= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109500] SIGABRT when calling a function that returns an unallocated value Date: Thu, 20 Apr 2023 16:29:08 +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: 12.0 X-Bugzilla-Keywords: accepts-invalid, diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: unassigned 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=3D109500 --- Comment #19 from Steve Kargl = --- On Thu, Apr 20, 2023 at 05:22:59AM +0000, kargl at gcc dot gnu.org wrote: >=20 > I think we agree on all points. Here's the diff I envision. > NOte, I've restricted it to user defined functions. Remove=20 > the esym check will enable it for any subprogram. >=20 >=20 > diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc > index db79b104dc2..f3bcdd76d6a 100644 > --- a/gcc/fortran/interface.cc > +++ b/gcc/fortran/interface.cc > @@ -3622,6 +3622,18 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, > gfc_formal_arglist *formal, > goto match; > } >=20 > + if (a->expr->expr_type =3D=3D EXPR_FUNCTION > + && a->expr->value.function.esym > + && f->sym->attr.allocatable) > + { > + if (where) > + gfc_error ("Actual argument for %qs at %L is a function resul= t " > + "and the dummy argument is ALLOCATABLE", > + f->sym->name, &a->expr->where); > + ok =3D false; > + goto match; > + } > + > /* Check intent =3D OUT/INOUT for definable actual argument. */ > if (!in_statement_function > && (f->sym->attr.intent =3D=3D INTENT_OUT >=20 The patch passes regtesting. PS: I think what you want to with a runtime check and an undefine function result is a good idea. I haven't looked to see where and how hard this might be to implement.=