Issue 160995
Summary [flang] string transfering may have an access out-of-bounds
Labels flang
Assignees
Reporter foxtran
    Assume that one has  the following code:

```Fortran
subroutine f_c_character(rhs, lhs, len)
   character(kind=c_char), intent(out) :: lhs(*)
   character(len=*), intent(in) :: rhs
   integer, intent(in) :: len
   integer :: length
   length = min(len-1, len_trim(rhs))

 lhs(1:length+1) = transfer(rhs(1:length), lhs(1:length)) // c_null_char

end subroutine f_c_character
```

Here is an assignment between two strings with possible truncation if rhs has larger length than lhs. 

However, flang runtime says that the `Assign: mismatching element counts in array assignment`

Here is an example with current master where the error occurs:
https://godbolt.org/z/bnacoM958

gfortran + ASan does not give any errors (except leaking).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to