public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109500] New: SIGABRT when calling a function that returns an unallocated value
@ 2023-04-13 13:24 leandro.lupori at linaro dot org
  2023-04-13 15:05 ` [Bug fortran/109500] " kargl at gcc dot gnu.org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: leandro.lupori at linaro dot org @ 2023-04-13 13:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109500

            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 = 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 function
that could return either an allocated result or an unallocated one, depending
on the argument, such as:

function f(p)
  integer, allocatable :: f, p

  if (allocated(p)) then
    f = p
  endif
end function

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2023-04-23 18:59 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 13:24 [Bug fortran/109500] New: SIGABRT when calling a function that returns an unallocated value leandro.lupori at linaro dot org
2023-04-13 15:05 ` [Bug fortran/109500] " kargl at gcc dot gnu.org
2023-04-13 17:06 ` leandro.lupori at linaro dot org
2023-04-13 18:12 ` kargl at gcc dot gnu.org
2023-04-13 18:32 ` anlauf at gcc dot gnu.org
2023-04-13 19:44 ` leandro.lupori at linaro dot org
2023-04-13 21:28 ` anlauf at gcc dot gnu.org
2023-04-13 21:34 ` sgk at troutmask dot apl.washington.edu
2023-04-14 19:24 ` anlauf at gcc dot gnu.org
2023-04-16 19:42 ` anlauf at gcc dot gnu.org
2023-04-17 12:14 ` leandro.lupori at linaro dot org
2023-04-17 20:20 ` anlauf at gcc dot gnu.org
2023-04-19 17:25 ` leandro.lupori at linaro dot org
2023-04-19 19:02 ` sgk at troutmask dot apl.washington.edu
2023-04-19 19:06 ` anlauf at gcc dot gnu.org
2023-04-19 19:15 ` anlauf at gcc dot gnu.org
2023-04-19 19:42 ` sgk at troutmask dot apl.washington.edu
2023-04-19 21:03 ` anlauf at gcc dot gnu.org
2023-04-20  5:22 ` kargl at gcc dot gnu.org
2023-04-20 16:29 ` sgk at troutmask dot apl.washington.edu
2023-04-20 19:02 ` anlauf at gcc dot gnu.org
2023-04-20 19:04 ` anlauf at gcc dot gnu.org
2023-04-20 20:02 ` anlauf at gcc dot gnu.org
2023-04-22 18:50 ` cvs-commit at gcc dot gnu.org
2023-04-23 18:59 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).