public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/98433] double free detected in tcache 2, after merge of structures
Date: Thu, 24 Dec 2020 12:01:45 +0000	[thread overview]
Message-ID: <bug-98433-4-ZNTzecgfD1@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98433-4@http.gcc.gnu.org/bugzilla/>

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2020-12-24
     Ever confirmed|0                           |1

--- Comment #5 from anlauf at gcc dot gnu.org ---
The user code is alright, it is the implementation of the intrinsic MERGE which
prevents doing the right thing when assigning to the l.h.s.

Extending the subroutine of the test program to

module bug_merge_m
  implicit none
contains
  subroutine bug_merge
    type t
       real, allocatable :: v(:)
    end type t

    type(t) :: x1, x2, x3, x4, x5
    logical :: f = .false.

    allocate(x1%v(1))
    x1%v = 1.
    allocate(x2%v(1))
    x2%v = 2.
    x3 = merge(x1, x2, .false.)
    print *, "x3%v = ", x3%v
    x4 = merge(x1, x2, f)
    print *, "x4%v = ", x4%v
    if (f) then; x5 = x1; else; x5 = x2; endif
    print *, "x5%v = ", x5%v
  end subroutine bug_merge
end module bug_merge_m

and looking a the generated dump-tree, one sees that the assignments to x3 and
x4 are generating wrong code, only the assignment to x5 is fine.

@Steve: that's pretty basic F2003 stuff, almost TR15581...

  parent reply	other threads:[~2020-12-24 12:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 22:18 [Bug fortran/98433] New: " guez at lmd dot ens.fr
2020-12-23 22:43 ` [Bug fortran/98433] " kargl at gcc dot gnu.org
2020-12-23 23:29 ` guez at lmd dot ens.fr
2020-12-24  0:52 ` sgk at troutmask dot apl.washington.edu
2020-12-24  7:55 ` guez at lmd dot ens.fr
2020-12-24 12:01 ` anlauf at gcc dot gnu.org [this message]
2020-12-24 19:31 ` kargl at gcc dot gnu.org
2020-12-24 23:03 ` guez at lmd dot ens.fr
2023-07-23 19:12 ` anlauf 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-98433-4-ZNTzecgfD1@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).