-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
flangFlang issues not falling into any other categoryFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
Assume that one has the following code:
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_characterHere 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).
This code works fine:
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) = transfer(rhs(1:length), lhs(1:length))
lhs(length+1:length+1) = c_null_char
end subroutine f_c_characterMetadata
Metadata
Assignees
Labels
flangFlang issues not falling into any other categoryFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!