<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/102935>102935</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
OpenMP "firstprivate" directive doesn't work for character strings with non-constant length
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang,
flang:openmp
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
psteinfeld
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVN2OszYQfRpzM0pkhvyQCy7SXUXdi6p9g5WBAdwaG9lDstunrwzJkkS7lT4pEvH4zMyZ42OrEHRriQqx_U1sXxM1cud8MQQmbRsydVK6-rP4nTwJ3AdQMHjXetUDd4ohdO4SgDuCRmkzehLZUchXIY9iJ6-_aXnLKsd2DgDofjC60gzWWboFK2UMhLEUmGcCD3O4cpaVtuEGCmPp3cja0hVqv6AAAGMgcP3wbnS5BLVlaskLfIn_LAvMdUyDyDg7gl2gVae8qjiCp8oQ2C-7gT2I7BUE4sfnvwLxLjGSj50D8bsd-3fuPKk6PAwTgQJTgRvXDzAor4whA432gQevz4pJYB5b3mcADF5bBoFHgS-x-Vw7Uo8c8GVq3BJfm8b-AvNYZMbHT6y6JDyM9TCYKquHwRa-ZOsvzsv-M7cf-8T05fTm6FRytse31nlr4A0q1w_aEHCnw5cFL5o7EDvZGGXblaULrBo3kO2H6LN1c4hFQNka6IOqkQk0R0Jv0BLPrnXGuIu2LbiRh5F_su8iNqRwp2R0wDzaHQLvEVHKZ4T8HvAc-FaHTtmWJu41VUZ5xdpZcM0UOiuvVWkoihKr7SSwg3Ja37s6u7l6JyOTqNBN4Hu1Ysmb1tpOy6B6gov6fJTx_8W710b-mnrfIn44gefAF4ukLrL6kB1UQkW6x2yTp5s0TboCKce6UlW5l0jbncybvFH7KtvkVZmVhybRBUrcyDzFdLeVabpOm_1OYtrUMt_mhzwTG0m90mZtzLlfO98mOoSRilTiIdsmRpVkwvS2Isanb7oQAnFy7NMqO87ejeHta-KLWHNVjm0QG2l04LB0Yc2Gij8Hsn_8Fa_Z4-uBUGtPFeszQe0oWIF7hovz_0Dj_PK-Rcm0bcN8kayzq8rZwMoyGLItd8noTdExDyGeLZ4EnlrN3ViuK9cLPEU-189q8O5vqljgaZIgCDxdVTgX-F8AAAD__9LF6I0">