public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109846] New: [rejects valid] Pointer-valued function reference rejected as actual argument
@ 2023-05-13 20:42 neil.n.carlson at gmail dot com
  2023-05-13 21:58 ` [Bug fortran/109846] " kargl at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: neil.n.carlson at gmail dot com @ 2023-05-13 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109846
           Summary: [rejects valid] Pointer-valued function reference
                    rejected as actual argument
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: neil.n.carlson at gmail dot com
  Target Milestone: ---

Gfortran rejects the following example.

module foo
  type :: parameter_list
  contains
    procedure :: sublist
  end type
contains
  function sublist(this) result(slist)
    class(parameter_list), intent(inout) :: this
    class(parameter_list), pointer :: slist
    allocate(slist)
  end function
end module

program example
  use foo
  type(parameter_list) :: plist
  call sub(plist%sublist())
contains
  subroutine sub(plist)
    type(parameter_list), intent(inout) :: plist
  end subroutine
end program

With this error:

   17 |   call sub(plist%sublist())
      |           1
Error: ‘sublist’ in variable definition context (actual argument to INTENT =
OUT/INOUT) at (1) is not a variable

It is accepted by both Intel OneAPI and NAG compilers. The sublist function
returns
a polymorphic pointer, which seems to be the source of the error. If it is
modified
to return a non-polymorphic pointer the example compiles without error.
Alternatively,
if the dummy argument intent is changed to intent(in) it also compiles without
error.

It is valid for a class(parameter_list) variable to be the actual argument for
a
type(parameter_list), intent(inout) dummy argument. So in light of 9.2/C902
(2018)
I think this is a gfortran bug.

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

end of thread, other threads:[~2023-05-20 20:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-13 20:42 [Bug fortran/109846] New: [rejects valid] Pointer-valued function reference rejected as actual argument neil.n.carlson at gmail dot com
2023-05-13 21:58 ` [Bug fortran/109846] " kargl at gcc dot gnu.org
2023-05-13 22:29 ` neil.n.carlson at gmail dot com
2023-05-14 19:15 ` [Bug fortran/109846] " anlauf at gcc dot gnu.org
2023-05-14 19:30 ` anlauf at gcc dot gnu.org
2023-05-14 20:05 ` anlauf at gcc dot gnu.org
2023-05-15 17:27 ` cvs-commit at gcc dot gnu.org
2023-05-18 16:54 ` cvs-commit at gcc dot gnu.org
2023-05-20 20:20 ` cvs-commit at gcc dot gnu.org
2023-05-20 20:37 ` cvs-commit at gcc dot gnu.org
2023-05-20 20:40 ` 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).