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...