public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juergen.reuter at desy dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/109209] [13 regression] erroneous error on assignment of alloctables
Date: Mon, 20 Mar 2023 15:54:45 +0000	[thread overview]
Message-ID: <bug-109209-4-l8li5udsNF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109209-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jürgen Reuter <juergen.reuter at desy dot de> ---
Here is the promised reproducer, which fails even when not using submodules:
$ gfortran -c reproducer.f90 
reproducer.f90:69:4:

   69 |     history_new(1:s) = res_set%history(1:s)
      |    1
Error: Component to the right of a part reference with nonzero rank must not
have the ALLOCATABLE attribute at (1)
reproducer.f90:69:23:

   69 |     history_new(1:s) = res_set%history(1:s)
      |                       1
Error: Component to the right of a part reference with nonzero rank must not
have the ALLOCATABLE attribute at (1)



module resonances
  implicit none
  private

  type :: t1_t
     integer, dimension(:), allocatable :: c
   contains
     procedure, private :: t1_assign
     generic :: assignment(=) => t1_assign
  end type t1_t

  type :: t3_t
     type(t1_t), dimension(:), allocatable :: resonances
     integer :: n_resonances = 0
  contains
     procedure, private :: t3_assign
     generic :: assignment(=) => t3_assign
  end type t3_t

  type :: resonance_branch_t
     integer :: i = 0
     integer, dimension(:), allocatable :: r_child
     integer, dimension(:), allocatable :: o_child
  end type resonance_branch_t

  type :: resonance_tree_t
     private
     integer :: n = 0
     type(resonance_branch_t), dimension(:), allocatable :: branch
  end type resonance_tree_t

  type :: t3_set_t
     private
     type(t3_t), dimension(:), allocatable :: history
     type(resonance_tree_t), dimension(:), allocatable :: tree
     integer :: last = 0
   contains
     procedure, private :: expand => t3_set_expand
  end type t3_set_t

contains

  pure subroutine t1_assign &
       (t1_out, t1_in)
    class(t1_t), intent(inout) :: t1_out
    class(t1_t), intent(in) :: t1_in
    if (allocated (t1_out%c))  deallocate (t1_out%c)
    if (allocated (t1_in%c)) then
       allocate (t1_out%c (size (t1_in%c)))
       t1_out%c = t1_in%c
    end if
  end subroutine t1_assign

  subroutine t3_assign (res_hist_out, res_hist_in)
    class(t3_t), intent(out) :: res_hist_out
    class(t3_t), intent(in) :: res_hist_in
    if (allocated (res_hist_in%resonances)) then
       res_hist_out%resonances = res_hist_in%resonances
       res_hist_out%n_resonances = res_hist_in%n_resonances
    end if
  end subroutine t3_assign

  module subroutine t3_set_expand (res_set)
    class(t3_set_t), intent(inout) :: res_set
    type(t3_t), dimension(:), allocatable :: history_new
    integer :: s
    s = size (res_set%history)
    allocate (history_new (2 * s))
    history_new(1:s) = res_set%history(1:s)
    call move_alloc (history_new, res_set%history)
  end subroutine t3_set_expand

end module resonances

  parent reply	other threads:[~2023-03-20 15:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20  9:20 [Bug fortran/109209] New: [13.0 " juergen.reuter at desy dot de
2023-03-20  9:29 ` [Bug fortran/109209] [13 " rguenth at gcc dot gnu.org
2023-03-20 11:37 ` juergen.reuter at desy dot de
2023-03-20 14:35 ` juergen.reuter at desy dot de
2023-03-20 15:51 ` juergen.reuter at desy dot de
2023-03-20 15:54 ` juergen.reuter at desy dot de [this message]
2023-03-20 16:00 ` juergen.reuter at desy dot de
2023-03-20 16:05 ` juergen.reuter at desy dot de
2023-03-20 16:25 ` juergen.reuter at desy dot de
2023-03-20 16:48 ` burnus at gcc dot gnu.org
2023-03-20 16:54 ` juergen.reuter at desy dot de
2023-03-20 16:56 ` juergen.reuter at desy dot de
2023-03-20 17:19 ` pault at gcc dot gnu.org
2023-03-20 17:21 ` burnus at gcc dot gnu.org
2023-03-20 17:44 ` pault at gcc dot gnu.org
2023-03-20 17:51 ` pault at gcc dot gnu.org
2023-03-20 17:55 ` anlauf at gcc dot gnu.org
2023-03-20 22:30 ` juergen.reuter at desy dot de
2023-03-21  6:22 ` cvs-commit at gcc dot gnu.org
2023-03-21  7:14 ` pault 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-109209-4-l8li5udsNF@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).