Using transfer with unallocated mold

Is it OK to pass an unallocated mold argument to transfer? For instance:

subroutine get_int32_key( key, value )
  type(key_type), intent(in)  :: key   ! Details of type definition elided
  integer(int32), allocatable, intent(out) :: value(:) ! Will be deallocated on input

  value = transfer( key % value, value ) ! Here value isn't allocated on the RHS
end subroutine

The question arose in a pull request review for stdlib – I’m the reviewer but not sure if this is standard. The code has tests which pass, but there are some reports of segfaults in another use case, and I wonder if this could be the issue.

In the standard I can’t find anything that would disallow using an unallocated mold

I also hit this problem; gfortran and AMD flang were happy with
MOLD unallocated, ifx gave an error message if -check all was used, and lfortran appeared to be stuck in an infinite loop. My test program:

 implicit none ! program transfertest.f90
  character(*),parameter:: string = 'ABC'
  character(1),allocatable::stringarray(:)
  stringarray = transfer(string,stringarray)
  print "(A)",stringarray
end program