1! { dg-do run }
2! PR 47674 - this would segfault if MALLOC_PERTURB is set.
3! This checks a code path where it is not possible to determine
4! the length of the string at compile time.
5!
6program main
7  implicit none
8  character(:), allocatable :: a
9  integer :: m, n
10  a = 'a'
11  if (a .ne. 'a') call abort
12  a = a // 'x'
13  if (a .ne. 'ax') call abort
14  if (len (a) .ne. 2) call abort
15  n = 2
16  m = 2
17  a = a(m:n)
18  if (a .ne. 'x') call abort
19  if (len (a) .ne. 1) call abort
20end program main
21