https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104382
Bug ID: 104382 Summary: Finalization of parent components not compliant with standard Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pault at gcc dot gnu.org Target Milestone: --- Created attachment 52349 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52349&action=edit Testcase for the problems With all branches that feature finalization, the attached testcase outputs: final_count after assignment = 0 destructor4(complicated) 4.00000000 5.00000000 destructor5 (simple2) -1 destructor5 (simple2) -2 destructor2(simple) 3 4 final_count after deallocation = 4 Ifort, on the other hand, outputs: destructor4(complicated) 2.000000 2.000000 destructor5 (simple2) 5 destructor5 (simple2) 6 destructor1(simple) 1 destructor1(simple) 1 final_count after assignment = 5 destructor4(complicated) 4.000000 5.000000 destructor5 (simple2) -1 destructor5 (simple2) -2 destructor1(simple) 3 destructor1(simple) 4 final_count after deallocation = 10 There are two problems: (i) The finalization of 'var' prior to reallocation is not ocurring. This is fixed by the patch that I posted to the list yesterday. (ii) The parent component is not being treated as a component, as mandated by F2018 7.5.6.2/1(3). Ifort is behaving correctly. Paul