public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110224] New: Rejects valid: function reference with data pointer result as lhs in assignment
@ 2023-06-12 13:14 neil.n.carlson at gmail dot com
  2023-06-13 16:49 ` [Bug fortran/110224] " anlauf at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: neil.n.carlson at gmail dot com @ 2023-06-12 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110224
           Summary: Rejects valid: function reference with data pointer
                    result as lhs in assignment
           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: ---

According to 9.2 of the F18 standard, a function reference that returns a data
pointer is a variable and can be used in variable definition contexts. In
particular it can be used as the selector in an associate construct (11.1.3.1,
C1101), however gfortran rejects this as invalid as shown by the following
example

module mod
  type :: foo
    real, pointer :: var
  contains
    procedure :: var_ptr
  end type
contains
  function var_ptr(this) result(ref)
    class(foo) :: this
    real, pointer :: ref
    ref => this%var
  end function
end module
program main
  use mod
  type(foo) :: x
  associate (var => x%var_ptr())
    var = 1.0
  end associate
  !x%var_ptr() = 2.0 ! THIS IS NOT REJECTED AS EXPECTED
end program

gfortran-20230612.f90:36:4:

   36 |     var = 1.0
      |    1
Error: ‘var’ at (1) associated to expression cannot be used in a variable
definition context (assignment)

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

end of thread, other threads:[~2023-06-22 13:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 13:14 [Bug fortran/110224] New: Rejects valid: function reference with data pointer result as lhs in assignment neil.n.carlson at gmail dot com
2023-06-13 16:49 ` [Bug fortran/110224] " anlauf at gcc dot gnu.org
2023-06-17 16:53 ` pault at gcc dot gnu.org
2023-06-20  9:48 ` pault at gcc dot gnu.org
2023-06-20 11:47 ` neil.n.carlson at gmail dot com
2023-06-20 11:53 ` neil.n.carlson at gmail dot com
2023-06-20 14:10 ` pault at gcc dot gnu.org
2023-06-20 14:42 ` neil.n.carlson at gmail dot com
2023-06-20 15:47 ` pault at gcc dot gnu.org
2023-06-20 16:36 ` neil.n.carlson at gmail dot com
2023-06-21 16:06 ` cvs-commit at gcc dot gnu.org
2023-06-21 21:05 ` pault at gcc dot gnu.org
2023-06-22 13:17 ` neil.n.carlson at gmail dot com

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