1! { dg-do run } 2! { dg-options "-Wcharacter-truncation" } 3! Tests the fix for PR31266: references to CHARACTER 4! components lead to the wrong length being assigned to substring 5! expressions. 6type data 7 character(len=5) :: c 8end type data 9type(data), dimension(5), target :: y 10character(len=2), dimension(5) :: p 11character(len=3), dimension(5) :: q 12 13y(:)%c = "abcdef" ! { dg-warning "in assignment \\(5/6\\)" } 14p(1) = y(1)%c(3:) ! { dg-warning "in assignment \\(2/3\\)" } 15if (p(1).ne."cd") STOP 1 16 17p(1) = y(1)%c ! { dg-warning "in assignment \\(2/5\\)" } 18if (p(1).ne."ab") STOP 2 19 20q = "xyz" 21p = q ! { dg-warning "CHARACTER expression will be truncated in assignment \\(2/3\\)" } 22if (any (p.ne.q(:)(1:2))) STOP 3 23end 24