https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98454
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-12-27
CC| |anlauf at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from anlauf at gcc dot gnu.org ---
I think there already exists at least one PR with issues with initializers.
A reduced testcase shows that default initialization works for intent(out),
whereas you get random junk for function results.
module m_test
implicit none
type t
integer :: unit = -1
end type t
interface test
module procedure test_fun
end interface
contains
function test_fun() result(res)
type(t) :: res
! res = t() ! <-- workaround
end function test_fun
subroutine test_sub (res)
type(t), intent(out) :: res
end subroutine test_sub
end module m_test
program p
use m_test
implicit none
type(t) :: x
write(6,*) 'Before constructor'
write(6,*) ' unit = ', x%unit
x = test()
write(6,*) 'After constructor (test_fun)'
write(6,*) ' unit = ', x%unit
call test_sub (x)
write(6,*) 'After test_sub'
write(6,*) ' unit = ', x%unit
end program p
If you need a workaround, uncomment the indicated line.