1! { dg-do compile }
2!
3! PR fortran/58579
4!
5! Contributed by Joost VandeVondele
6!
7! Was ICEing before due to the patch for PR 58593
8!
9  subroutine test
10    CHARACTER(len=20)                        :: tmpStr
11    CHARACTER(len=20, kind=4)                :: tmpStr4
12    INTEGER :: output_unit=6
13       WRITE (UNIT=output_unit,FMT="(T2,A,T61,A20)")&
14         "DFT| Self-interaction correction (SIC)",ADJUSTR(TRIM(tmpstr))
15       WRITE (UNIT=output_unit,FMT="(T2,A,T61,A20)")&
16         4_"DFT| Self-interaction correction (SIC)",ADJUSTR(TRIM(tmpstr4))
17   END
18
19!
20! PR fortran/58593
21! Contributed by Albert Bartok
22!
23! The PR was overallocating memory. I placed it here to check for a
24! variant of the test case above, which takes a slightly differnt code
25! patch. Thus, its purpose is just to ensure that it won't ICE.
26!
27program test_char
28
29   implicit none
30   integer :: i
31
32   read*, i
33   print*, trim(test(i))
34
35   contains
36
37      function test(i)
38         integer, intent(in) :: i
39         character(len=i) :: test
40
41         test(1:1) = "A"
42      endfunction test
43
44endprogram test_char
45