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.
8 ! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
13 character (len
=5) :: x
, y
14 character (len
=5) :: z(2)
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 ()
24 z
= (/y(1: len (trim(y
))), x(1: len (trim(x
)))/)
25 end program array_char
27 ! { dg-output "At line 24 of file .*" }
28 ! { dg-output "Different CHARACTER lengths .2/1. in array constructor" }