[Bug fortran/125428] [14/15/16/17 Regression] Finalization in an assignment drops some initialization code

albert at tugraz dot at via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125428

Christopher Albert <albert at tugraz dot at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |albert at tugraz dot at,
                   |                            |jvdelisle at gcc dot gnu.org

--- Comment #4 from Christopher Albert <albert at tugraz dot at> ---
Open for review, comments welcome:
https://github.com/lazy-fortran/gcc/pull/42

Root cause: for a scalar derived-type assignment,
gfc_trans_assignment_1 converted the lhs expression a second time for
finalization and for the scalar allocation guard. That repeated
conversion could omit prerequisite statements for component
temporaries, so the finalizer or the reallocation path saw
uninitialized state. The fix threads the already stabilized lhs into
the finalization call, its allocation guard, and
alloc_scalar_allocatable_for_assignment instead of regenerating it.
Includes a run test. check-fortran and the libgomp Fortran suite are
clean; the finalize_62.f90 test from fork PR 38 still passes.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.