1! { dg-do run } 2! 3! Test the fix for PR58618 by checking that substring associate targets 4! work correctly. 5! 6! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com> 7! 8 character(5) :: s(2) = ['abcde','fghij'] 9 character (6), pointer :: ptr => NULL() 10 character (6), target :: tgt = 'lmnopq' 11 12 associate (x=>s(2)(3:4)) 13 if (x .ne. 'hi') stop 1 14 x = 'uv' 15 end associate 16 if (any (s .ne. ['abcde','fguvj'])) stop 2 17 18! Unity based substrings are cast differently. */ 19 associate (x=>s(1)(1:4)) 20 if (x .ne. 'abcd') stop 3 21 x(2:3) = 'wx' 22 end associate 23 if (any (s .ne. ['awxde','fguvj'])) stop 4 24 25! Make sure that possible misidentifications do not occur. 26 ptr => tgt 27 associate (x=>ptr) 28 if (x .ne. 'lmnopq') stop 5 29 x(2:3) = 'wx' 30 end associate 31 if (tgt .ne. 'lwxopq') stop 6 32 33 associate (x=>ptr(5:6)) 34 if (x .ne. 'pq') stop 7 35 x = 'wx' 36 end associate 37 if (tgt .ne. 'lwxowx') stop 8 38 end 39