https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105170
Bug ID: 105170 Summary: Invalid finalization in intrinsic assignment Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: baradi09 at gmail dot com Target Milestone: --- Created attachment 52754 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52754&action=edit Minimal working example demonstrating the bug I have a derived type (TWrapper), which has a component with defined assignment. The containing derived type itself has no defined assignment. Upon an assignment between two TWrapper instances, a copy of the RHS seems to get finalized. The attached MWE demonstrates the problem. Expected output (as delivered by current Intel and NAG compilers): RefCounter_final, id:0 TRefCounter_init: id:42 -> Assignment wrapper2 = wrapper TRefCounter_final, id:0 TRefCounter_final, id:0 TRefCounter_assign: this%id, other%id: 0 42 GFortran output: TRefCounter_final, id:0 TRefCounter_init: id:42 -> Assignment wrapper2 = wrapper TRefCounter_final, id:42 TRefCounter_assign: this%id, other%id: 0 42 One finalization seems to be missing. Additionally, the finalized instance seems to be a copy of the RHS. (A copy, because after the finalization, the RHS still seems to have kept its id-value...)