public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikael at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out)
Date: Mon, 10 Jul 2023 18:26:28 +0000	[thread overview]
Message-ID: <bug-110618-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110618
           Summary: Dependency between arguments when one is allocatable
                    array whose dummy is intent(out)
           Product: gcc
           Version: 11.4.1
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikael at gcc dot gnu.org
                CC: abensonca at gcc dot gnu.org, anlauf at gcc dot gnu.org,
                    burnus at gcc dot gnu.org, kargl at gcc dot gnu.org,
                    vladimir.fuka at gmail dot com
        Depends on: 92178
            Blocks: 87142
  Target Milestone: ---

+++ This bug was initially created as a clone of Bug #92178 +++

PR 92178 has several cases of dependency between arguments when one of them is
deallocated before the call in the process of argument association.

Here is another example which I don't want to handle there (and which I don't
know how to fix).

program p
  implicit none
  type t
    integer :: i
  end type t
  type u
    class(t), allocatable :: ta(:)
  end type u
  type(u), allocatable :: c(:)
  class(t), allocatable :: d(:)
  allocate(c, source = [u([t(1), t(3)]), u([t(4), t(9)])])
  allocate(d, source = [t(1), t(5)])
  call bar (                   &
      allocated(c(d(1)%i)%ta), &
      d,                       &
      c(d(1)%i)%ta,            &
      allocated (c(d(1)%i)%ta) &
  )
  if (allocated (c(1)%ta)) stop 11
  if (.not. allocated (c(2)%ta)) stop 12
contains
  subroutine bar (alloc, x, y, alloc2)
    logical :: alloc, alloc2
    class(t), allocatable, intent(out) :: x(:)
    class(t), allocatable, intent(out) :: y(:)
    if (allocated (x)) stop 1
    if (.not. alloc)   stop 2
    if (.not. alloc2)  stop 3
  end subroutine bar
end


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87142
[Bug 87142] Aliasing issue with overloaded assignment and allocatable
components
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92178
[Bug 92178] Segmentation fault after passing allocatable array as intent(out)
and its element as value into the same subroutine

             reply	other threads:[~2023-07-10 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 18:26 mikael at gcc dot gnu.org [this message]
2023-07-10 20:53 ` [Bug fortran/110618] " mikael at gcc dot gnu.org
2023-07-13 19:29 ` mikael at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 17:46 ` mikael at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110618-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).