https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67444
Bug ID: 67444 Summary: RHS of overloaded assignment not finalized Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: baradi09 at gmail dot com Target Milestone: --- Created attachment 36291 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36291&action=edit Fortran file demonstrating the issue Dear developer, Thank you for your continuous effort to provide a free Fortran compiler with OOP-features. In my oppinion, Gfortran behaves incorrectly, when instances of polymorphic types with user defined constructors are assigned to each other. Having an assignment of the type a = MyType() where also "a" is type(MyType) I'd expect expect following calling sequence: * Constructor for MyType() producing the LHS * Destructor (final procedure) of MyType finalizing instance "a" * Assignment of MyType * Destructor for MyType to finalize the RHS of the assignment. According to the attached example, however, the last step is missing. I've checked the example with two other compilers, they all produced the sequence as given above. With gfortran, I get the output Starting using Basic: initBasic START initBasic END Destructing Basic -1 assignBasic START assignBasic END Values in basic: 43 Destructing Basic 43 while the correct one (with the additional line 7) should be. Starting using Basic: initBasic START initBasic END Destructing Basic -1 assignBasic START assignBasic END Destructing Basic 42 Values in basic: 43 Destructing Basic 43