<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61976>61976</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
flang: Operations with complex floating point numbers give unexpected results on MinGW
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mmuetzel
</td>
</tr>
</table>
<pre>
The following code compiled with `flang` 16.0.0 installed from MSYS2 gives unexpected results:
```
program test
implicit none
complex :: z = cmplx(0., 1.)
print*, z**2
end program
```
Result:
```
$ flang test-pow.f90 -o test-pow
$ ./test-pow
(1.5440984E+23,0.)
$ ./test-pow
(1.3455499E-28,0.)
$ ./test-pow
(5.51239E-25,0.)
$ ./test-pow
(Inf,0.)
```
It almost looks like random memory is dereferenced for the real part, and the imaginary part contains the result I'd actually expect for the real part.
It is working correctly with `gfortran`:
```
$ gfortran test-pow.f90 -o test-pow
$ ./test-pow
(-1.00000000,0.00000000)
```
If there is anything I can do to help debugging, please let me know.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE2P2zYQ_TXUZWCBGn1YOujgZOPCh6BAU6DokZJGErv8EEgqXu-vLyhrd5N22yKoYIAgZx793uPgCe_lZIhaVn5g5UMi1jBb12q9UngmlXR2uLW_zgSjVcpepZmgtwNBb_UiFQ1wlWEGVvFRCTOxikNWpTzlII0PQsWO0VkNn7_8_gVhkl_Jw2roaaE-0ACO_KqCZ_mJ8QfGT6zi-2_bLs5OTmgI5MP9BKRelOxlAGMN7WcbG0VPEO_JT_AMLH-AXi_qiWHNU4YfIUsZNi_9i5MmMDzFwvO2nvBeIzPA_q_vMvplI_xPfBkWsBmxMT4s9pqODYeDfd3vfa_dKcPz9zVgWGdpWRS8qYtPDD9gzvAjf6P_3-C8KMuiaT4dsP4xaJmWGeYRWP4Y8GLGvwC-N-YSQChtfQBl7aMHJR8JnDCD1aBJW3cD6WEgRyM5Mn0cG-sgzASOhIJFuBAfS5hhO5RaTNIId9sq0FsThDR-B8QnggvD4wCiD6tQ6gb3kfv7rem3Ai8h0rha93gfdOeoD-r2OuTTaF1wwkRd_zICL23_Zwq--RjWhyzl-7f5_LZ53-9dzhi1OoqihLmFOaq6QC8MDBaChZnUAgN16zRJM0WDF0XCEygKoAkejb3uBiVDmw9N3oiE2qyq-fGY8yxL5raiquuPyMuirIo-41XZ8SOKASuONTZjIlvkmPOCV7zBPM9S5FQfcax6PhZNVles4KSFVKlSX3Vq3ZRI71dqq6w5VokSHSm_5ROioStsRYYY48q1EXPo1smzgivpg3-7JcigqL0HU36CnxdyIkhr_P09X0JjVFaE6MxipQlgVt2R81tWvRNVYA18luan35LVqXYOYdnSC88Mz5MM89qlvdUMz5HGvhwWZ_-gPjA8b-Q9w_Mm7s8AAAD__wSVnjI">