1! { dg-do run }
2!
3! Checks the fix for PR67977 in which automatic reallocation on assignment
4! was performed when the lhs had a substring reference.
5!
6! Contributed by Anton Shterenlikht  <mexas@bristol.ac.uk>
7!
8  character(:), allocatable :: z
9  integer :: length
10  z = "cockatoo"
11  length = len (z)
12  z(:) = ''
13  if (len(z) .ne. length) STOP 1
14  if (trim (z) .ne. '') STOP 2
15  z(:3) = "foo"
16  if (len(z) .ne. length) STOP 3
17  if (trim (z) .ne. "foo") STOP 4
18  z(4:) = "__bar"
19  if (len(z) .ne. length) STOP 5
20  if (trim (z) .ne. "foo__bar") STOP 6
21  deallocate (z)
22end
23