public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109575] New: Implement runtime check for valid function result
@ 2023-04-20 19:36 anlauf at gcc dot gnu.org
  2023-04-20 21:10 ` [Bug fortran/109575] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-20 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109575
           Summary: Implement runtime check for valid function result
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Split off from the discussion in pr109500: consider

program main
  implicit none
  integer, allocatable  :: p
  p = f()          ! <- this assignment may fail
  print *, allocated (p)
contains
  function f()
    integer, allocatable :: f
    allocate (f, source=42)
    deallocate (f) ! <- this renders the function invalid
  end function
end

This code is invalid as the function result must be defined:

F2018:15.6.2.2

On completion of execution of the function, the value returned is that
of its function result. If the function result is a data pointer, the
shape of the value returned by the function is determined by the shape
of the function result when the execution of the function is completed.
If the function result is not a pointer, its value shall be defined by
the function. If the function result is a pointer, on return the pointer
association status of the function result shall not be undefined.


A runtime check that can detect the failing assignment needs to check
that the function result is defined when the function returns.

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

end of thread, other threads:[~2023-04-21 21:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 19:36 [Bug fortran/109575] New: Implement runtime check for valid function result anlauf at gcc dot gnu.org
2023-04-20 21:10 ` [Bug fortran/109575] " kargl at gcc dot gnu.org
2023-04-21 20:24 ` anlauf at gcc dot gnu.org
2023-04-21 21:32 ` sgk at troutmask dot apl.washington.edu

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).