1! { dg-do run }
2!
3! PR fortran/58771
4!
5! Contributed by Vittorio Secca  <zeccav@gmail.com>
6!
7! ICEd on the write statement with f() because the derived type backend
8! declaration not built.
9!
10module m
11  type t
12    integer(4) g
13  end type
14end
15
16type(t) function f() result(ff)
17  use m
18  ff%g = 42
19end
20
21  use m
22  character (20) :: line1, line2
23  type(t)  f
24  write (line1, *) f()
25  write (line2, *) 42_4
26  if (line1 .ne. line2) call abort
27end
28