public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102641] New: Bogus error for intent(out) dummy that is a polymorphic assumed-rank array
@ 2021-10-07 15:15 sandra at gcc dot gnu.org
  2021-10-07 16:08 ` [Bug fortran/102641] " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-10-07 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102641
           Summary: Bogus error for intent(out) dummy that is a
                    polymorphic assumed-rank array
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sandra at gcc dot gnu.org
  Target Milestone: ---

A trivial subroutine with a intent(out) dummy that is a polymorphic
assumed-rank array...

module m

contains
    subroutine s1 (x, y)
      class(*) :: x(..)
      class(*), intent (out) :: y(..)
    end subroutine

end module

...incorrectly produces a compilation error:

unlimited1.f90:4:23:

    4 |     subroutine s1 (x, y)
      |                       1
Error: Assumed-rank variable y at (1) may only be used as actual argument

This error is arising from references to the intent(out) argument in the
automatically-generated deallocation and initialization code.  Probably some
flag needs to be added to the references in that code to suppress the warning,
which is coming from resolve_variable in resolve.c.

Of course runtime testing is needed as well to ensure that the generated
initialization code DTRT with assumed-rank arrays -- it's obviously never been
tested.  In fact, I wonder if the initialization code generator is even
equipped to handle arrays whose rank is unknown at compile time.  (I'm not
familiar with the code to implement it, but I see a loop nest coming out of the
front end for fixed-rank arrays.)

I ran into this error while working on PR 54753 (diagnostic for C839 involving
assumed-size actual arguments passed to assumed-rank dummies), but it's a
different issue unrelated to invalid calls, so I'm giving it its own issue. 
The patch Tobias already committed that was tagged PR 54753 only fixed
interface declarations by suppressing the unused initialization code entirely,
as a workaround to unblock testing of the actual fix for PR 54753.

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

end of thread, other threads:[~2021-10-23 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 15:15 [Bug fortran/102641] New: Bogus error for intent(out) dummy that is a polymorphic assumed-rank array sandra at gcc dot gnu.org
2021-10-07 16:08 ` [Bug fortran/102641] " burnus at gcc dot gnu.org
2021-10-07 17:04 ` sandra at gcc dot gnu.org
2021-10-23 22:12 ` sandra 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).