From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 667873858C83; Fri, 21 Apr 2023 20:24:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 667873858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682108686; bh=Tk8wUJriHV1rjzcICMZCmcn7tDpRi82fJdE46DMi9IQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XRfDPPrGG7QkbDo27L5TvoOu40tXJGsCiztQgmYtLdrGDga2z9BH7PmQBpJkW/Gde +4AGhFMXGHPs8VJyBpRQPb8vrs2w9FapAXNpROFGdl5EjfNJz5DWqQkz+p0iSTR/mp zRa3wKOokq4Rgqw+e60D7X0aVQXeTjEavZm+o/rg= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109575] Implement runtime check for valid function result Date: Fri, 21 Apr 2023 20:24:45 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 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=3D109575 --- Comment #2 from anlauf at gcc dot gnu.org --- I have some idea how (and where) the runtime checks need to be implemented, but I am confused by the following observations on the occurence of an explicit RETURN statement and the use of a RESULT variable: function f() integer :: f end function f1() integer :: f1 f1 =3D 1 end function q() result (f) integer :: f end function q2() result (f) integer :: f f =3D 2 end function g() integer :: g return end function g3() integer :: g3 g3 =3D 3 return end function r() result (f) integer :: f return end function r4() result (f) integer :: f f =3D 4 return end While the dump-fortran-original does not show any surprises, the tree-dump looks somewhat irregular: __attribute__((fn spec (". "))) integer(kind=3D4) f () { (void) 0; } __attribute__((fn spec (". "))) integer(kind=3D4) f1 () { integer(kind=3D4) __result_f1; __result_f1 =3D 1; return __result_f1; } __attribute__((fn spec (". "))) integer(kind=3D4) q () { (void) 0; } __attribute__((fn spec (". "))) integer(kind=3D4) q2 () { integer(kind=3D4) f; f =3D 2; return f; } __attribute__((fn spec (". "))) integer(kind=3D4) g () { integer(kind=3D4) __result_g; return __result_g; return __result_g; } __attribute__((fn spec (". "))) integer(kind=3D4) g3 () { integer(kind=3D4) __result_g3; __result_g3 =3D 3; return __result_g3; return __result_g3; } __attribute__((fn spec (". "))) integer(kind=3D4) r () { return; } __attribute__((fn spec (". "))) integer(kind=3D4) r4 () { integer(kind=3D4) f; f =3D 4; return f; return f; } This seems to correspond to two different paths to gfc_generate_return().=