<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120724>120724</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][openmp] crash in complex atomic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeanPerier
</td>
</tr>
</table>
<pre>
```
complex c
integer :: i
c=(1.0,1.0)
call omp_set_num_threads(4)
!$omp parallel do
do i = 1, 100000000
!$omp atomic
c = c + (1.0,1.0)
end do
print *, c
end
```
Segfaults in __atomic_compare_exchange
```
#0 0x00007ffff7fa46c7 in __atomic_compare_exchange () from /lib/x86_64-linux-gnu/libatomic.so.1
#1 0x0000555555555418 in _QQmain..omp_par () at repro.f90:7
#2 0x00007ffff62c3239 in __kmp_invoke_microtask () from lib/libomp.so
#3 0x00007ffff624041f in __kmp_invoke_task_func () from lib/libomp.so
#4 0x00007ffff623f07e in __kmp_launch_thread () from lib/libomp.so
#5 0x00007ffff62a2f18 in __kmp_launch_worker(void*) () from lib/libomp.so
#6 0x00007ffff5e94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#7 0x00007ffff5f26660 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
````
If I lower the loop iteration from 100000000 to 1000000, I do not see such crash and the expected number is printed.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyElMuOozgUhp_G2ViFzLG5LVikKhOpdtPqB0COOYC7jI1sk07P04-4pCrRjFQoCsJwvv-3z0WGoHuLWJPslWSng5zj4Hz9C6X9G71Gf7i49k9Ncrb_2JEqN04Gb1QtD1TbiD16SviR8CPV66Ii_ESgTBNG4G39r7Z1aQx149QEjI2dxyYOHmUbCJRi_4ZASkC4caKT9NIYNLR1azCltHVUU8JPNCXwRlO2X_fXX7EyulGr-7paYxQl8Er_zxba9i4yeW0jJXBcBBYA2paw4-MBEHb8iX0nZxMD1ZY2zabWLAcjPTZ4U4O0PdLt46dY4IxSdltcF13XdUUnRa6KbzhQEqho591ICZyNvhA438q8ycWL0Xa-vfR23l5siCS4JN3k0l0tu18iLVe1Hz9GqW2SLOmYpL-LyEg9Tt4lXcUIPxYbBR4956A48Grz_DFOjbZX94HNqJV3UYaPJ8ObW6MvbpyS4DYef-YJJtLuP7wF1XSzVd_zxDOPd6zAL56Rs1XDXmzfw7JnmIRuP7JH2G_nP9ATKK9Ot2u9VN-T80dyhpWQii_kEKWPD_6k75cO4m9uinrU_2BL3RwJ_2vPUELgbKdoCJynLapRHmXERBF-FAI2ueKp1LIO8jxni54yziJ_SHmyEMOf0OIUCJxnq2_bwnXdhJ1vnxVH4LyFJz8JP5bpU4XfG-S9o-_UuN_oaRyQGucmqiN6GbWz2wF9di-N7v6wNN370uXWRRoQaZjVQJWXYaDStisLbxOqiC2183hBT3XYmhbb5NDWvK14JQ9YpwUXeVVklTgMNXLFsiJHXrY5412atpC1XGCZAqqiYgddAwORArAUIOciEZlS0KayLCAVKCURDEepTWLMdUyc7w86hBnrFFgB4mDkBU1YpyhAZ6TtCcAyUH29BLxc5j4QwYwOMXwhoo5mHb1bRHYi2aub0I4TyU77tpds7QN36-3D7E09xDiFZeTCmcC513GYL4ly45Itc73fXibvfqGKBM6r2yW1u-FrDf8GAAD__8nFyh8">