Bug 71798 - [OOP] failure to finalise temporary
Summary: [OOP] failure to finalise temporary
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: Finalization
  Show dependency treegraph
 
Reported: 2016-07-07 13:25 UTC by Jonathan Hogg
Modified: 2018-09-28 06:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-07 00:00:00


Attachments
test case (326 bytes, text/plain)
2016-07-07 13:25 UTC, Jonathan Hogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Hogg 2016-07-07 13:25:11 UTC
Created attachment 38855 [details]
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
Comment 1 Dominique d'Humieres 2016-07-07 15:41:35 UTC
Confirmed from 4.9 up to trunk (7.0). Finalization is not implemented in 4.8.
Comment 2 Jürgen Reuter 2018-09-28 06:24:19 UTC
Still present in actual trunk.