From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A6ECA3858D33; Wed, 19 Apr 2023 19:15:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6ECA3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681931750; bh=1Umz5nyfH2yw3R2xz3JfTp9qEKQahHRXP9gNxXkbNfE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f0eROkQ6GGVRiorzTWoFGCA0dQrgL+aNceVbU29/IHvWgeStz2flf7VzZSInTJJr3 6KD5or0HpAl4lQWN+vBW+hatFP7ktgarWhFpoghpmBfUHSQCgTb3YHP0PofvGcvQFx oa+ryuCfSU8/r/G6XySDLUQh00r9vSPaXI1rKFJk= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109500] SIGABRT when calling a function that returns an unallocated value Date: Wed, 19 Apr 2023 19:15:50 +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: anlauf at gcc dot gnu.org 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 #15 from anlauf at gcc dot gnu.org --- (In reply to Steve Kargl from comment #13) > Note 1 in Fortran 2023, Sec. 8.5.3, p. 100, is non-normative > text. I suppose one can claim that gfortran should throw an > error when a function result is marked with the allocatable > attribute. You mean when the function result is not allocated in that case? > Unfortunately, it is likely a catch-22 situation > in that gfortran needs to know the function result is allocatable > so it can do the allocaton within the function, but it is not > an allocatable outside of the function. Not sure gfortran > can mark an internal symbol to do both. I checked how to implement a run-time check for a non-allocated function result, but did this in the wrong place - in the caller. This did work when I did allocate and the deallocate before return, otherwise the result variable is simply undefined, and the check does not work. So a run-time check needs to be put where the function return is generated.=