https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71798
Bug ID: 71798 Summary: failure to finalise fortran temporary Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jonathan.hogg at stfc dot ac.uk Target Milestone: --- Created attachment 38855 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38855&action=edit test case Compiling and running the attached code we get: $ gfortran-6 -o assign_final assign_final.f90 && ./assign_final Creating 1 Assigned 2 1 This seems like a missing finalisation on copy assignment? 1) One might expect there to be a move assignment, and to get the following output: Creating 1 [created in-place for x] Finalised 1 [may not happen if final not called on exit from program?] 2) Or a copy assignment, and to get the following: Creating 1 [create as temporary] Assigned 2 1 [copy temporary to x] Finalised 1 [temporary destroyed] Finalised 2 [may not happen if final not called on exit from program?] I note that the intel compiler gives the second sequence, minus cleanup on exit. $ ifort -o assign_final assign_final.f90 && ./assign_final Creating 1 Assigned 2 1 Finalised 1 I'm using the following version of gfortran: GNU Fortran (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511