Issue 102935
Summary OpenMP "firstprivate" directive doesn't work for character strings with non-constant length
Labels bug, flang, flang:openmp
Assignees
Reporter psteinfeld
    Here's a program that shows the failure:
```
program bug
  implicit none
  call sub(3)
contains
  subroutine sub(n)
    use omp_lib
    integer,intent(in) :: n
    character(n) str
    str = "xyz"
    call omp_set_num_threads(3)
    !$omp parallel firstprivate(str)
      print *, "thread: ", omp_get_thread_num(), ", str: ", str
      str = "abc"
    !$omp end parallel
    print *, "str: ", str
  end subroutine
end program
```
If I compile this program with `flang-new -fopenmp bug.f90` and execute it, I get the following output:
```
thread:  1 , str: xyz
 thread:  2 , str: abc
 thread: 0 , str: abc
 str: abc
```
If I change the declaration of the variable `str` to be `character(3) str`, and compile and execute the program in the same way, I get the output:
```
 thread:  0 , str: xyz
 thread:  2 , str: xyz
 thread:  1 , str: xyz
 str: xyz
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to