public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "federico.perini at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59202] Erroneous argument aliasing with defined assignment Date: Thu, 03 Jun 2021 08:35:59 +0000 [thread overview] Message-ID: <bug-59202-4-J5gksKwjLG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-59202-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59202 --- Comment #4 from federico <federico.perini at gmail dot com> --- The self-assignment issue is present even if the derived type has no allocatable components. Here is a sample test program that gives an error with gfortran 10.2.0: module assign implicit none private type, public :: t integer :: a contains procedure :: destroy=>t_destroy procedure :: assign=>t_assign generic :: assignment(=) =>assign end type t contains elemental subroutine t_destroy(this) class(t), intent(inout) :: this this%a = 0 end subroutine t_destroy subroutine t_assign(this,that) class(t), intent(inout) :: this class(t), intent(in) :: that call this%destroy() ! Clean memory first select type (thatPtr=>that) type is (t) this%a = thatPtr%a end select end subroutine t_assign end module assign program test use assign type(t), allocatable :: t1(:) allocate(t1(10)) do i=1,10 t1(i)%a = i end do n = 0 do i=1,10 if (mod(i,2)/=0) then n = n + 1 t1(n) = t1(i) print *, 'i=',i,' t(i)%a=',t1(i)%a,' expected t(i)%a=',i,': ',merge('ERROR!','OK ',t1(i)%a/=i) endif end do end program test
prev parent reply other threads:[~2021-06-03 8:35 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-59202-4@http.gcc.gnu.org/bugzilla/> 2014-03-22 15:41 ` dominiq at lps dot ens.fr 2021-06-01 15:38 ` vladimir.fuka at gmail dot com 2021-06-03 8:34 ` federico.perini at gmail dot com 2021-06-03 8:35 ` federico.perini at gmail dot com [this message]
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-59202-4-J5gksKwjLG@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: linkBe 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).