1! { dg-do run }
2! { dg-options "-fbounds-check" }
3! { dg-shouldfail "Different CHARACTER lengths" }
4! Tests the fix for PR34396, where the non-constant string lengths in the
5! array constructor were being ignored and the bounds checking was not
6! being done correctly.
7!
8! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
9!
10program array_char
11  implicit none
12  integer :: i, j(5)
13  character (len=5) :: x, y
14  character (len=5) :: z(2)
15  x = "ab"
16  y = "cd"
17  z = ""
18  z = (/y(1: len (trim(y))), x(1: len (trim(x)))/)
19  j = ichar ([(z(1)(i:i), i=1,5)])
20  if (any (j .ne. (/99,100,32,32,32/))) call abort ()
21  j = ichar ([(z(2)(i:i), i=1,5)])
22  if (any (j .ne. (/97,98,32,32,32/))) call abort ()
23  x = "a "
24  z = (/y(1: len (trim(y))), x(1: len (trim(x)))/)
25end program array_char
26
27! { dg-output "At line 24 of file .*" }
28! { dg-output "Different CHARACTER lengths .2/1. in array constructor" }
29