https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98454
--- Comment #10 from anlauf at gcc dot gnu.org --- (In reply to martin from comment #9) > Problems with default initialisation of function result were fixed with > PR45489. The relevant testcase added by this PR is initialization_27.f90 > which looks very similar to the reported problem (minus the non-initialised > components). Maybe they were addressed, but not fixed. A further reduced testcase for the present problem: program p implicit none type t integer :: unit = -1 end type t type(t) :: x x = g() if (x% unit /= -1) stop 2 x = f() if (x% unit /= -1) stop 3 contains function f() type(t) :: f end function f function g() type(t) :: g if (g% unit /= -1) stop 1 end function g end The program fails with STOP 3 Looking into the tree-dump shows that g() is fine, f() is not. Thanks for the pointer to PR45489, which may provide a starting point.