From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 67F5D3858D33; Thu, 13 Apr 2023 13:24:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67F5D3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681392286; bh=0T8d4n92RUDU2sGdnbARovvntOufbMUvGw9RuxsjCFo=; h=From:To:Subject:Date:From; b=t8LolpwFcjIR4AE86xHzzdAJz88PIXJNIS+Zbv9g5ySh2xkHX9iYX02kMQ86kPMrs XSeIfR1RJKA6WJYPiTvb+hWTUx6Req1S8aGC32cmB1IGbaefqcKJkAS3PmSqfRiSYc CUIR2JQ22R/44g3lSJ7GKzi3A5N2PLBi6mSEZeRo= From: "leandro.lupori at linaro dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109500] New: SIGABRT when calling a function that returns an unallocated value Date: Thu, 13 Apr 2023 13:24:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: leandro.lupori at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 109500 Summary: SIGABRT when calling a function that returns an unallocated value Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: leandro.lupori at linaro dot org Target Milestone: --- While doing some tests with functions that return an allocatable result, I found out that the following program receives a SIGABRT: program main print *, is_allocated(f()) contains function f() integer, allocatable :: f end function logical function is_allocated(p) integer, allocatable :: p is_allocated =3D allocated(p) end function end program This is the output (without the backtrace): free(): invalid pointer Program received signal SIGABRT: Process abort signal. I tested it with gfortran 11.3.0 and 12.0.0 20220117 (experimental) [master r12-6624-gb75aab194e3] (from gcc-snapshot). The program above is a reduced version. I was actually trying to use a func= tion that could return either an allocated result or an unallocated one, dependi= ng on the argument, such as: function f(p) integer, allocatable :: f, p if (allocated(p)) then f =3D p endif end function=