<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87349>87349</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Imaginary part contains random information when passing real parameter to complex dummy argument
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DavidTruby
</td>
</tr>
</table>
<pre>
When passing a real to a subroutine that expects a complex, the imaginary part of the complex is not zeroed but has random values in it. In the following case as an example:
```
subroutine prcplx(cx)
implicit none
complex :: cx
print *, "value", cx
end subroutine
program complex_args
implicit none
real, parameter :: val = 123.0
call prcplx(val)
end program
```
a warning is issued that "If the procedure's interface were explicit, this reference would be in error" but the code still compiles, and the complex value is incorrect.
Classic flang and gfortran both zero the imaginary part.
We observed this behaviour in a real application so even though the code is probably not strictly correct it would be good to get this fixed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2L4zgQ_TXypZjgyM7XwYfeCYG-L8xxKUtlW4ssmZKUTvbXL1LckzQ0A4Fgu-rpvVevhCGY0RF1YveX2J0rTHHy3J3xavTfnPp71Xt9735N5GDJxW4EBCa0ED0ghNSzT9E4gjhhBLotpGIABOXnxdJNyJ8QJwIz42gc8h0W5Ah-KG_XIjABnI_wH7EnDX2KMGEARqf9DFe0iQIYByZu4N2VzsFb6z8yHYWBAAOgA7phxhPNm6jPon4T-3r9lccXsgurxd6EPKqbkKfHZwAzL9YoE8F5R-vLT4oZtHkDdVuh15aFjYsg5FsWKqQsZIWU-fGzlpx-Meq1f2E_Ms6fh_yDPIY_kSnOZ-gFGWeKxJ-8rmhBNGfYymZTf6Wo0Nqn4GsGOD2JrRS-NQzhA9llk00AE0Ii_RizkPL9McGFvSKdmIQ85BlF4gEVwQcx5TQUCY8QmABMAzG5_N0nq6GnPFZi9iykLIN_xEIThGisLc4YSyFDoNNfUlO8LtSc8syk4uZV-U-bA6tgsJhT6zSMg-fI6KD3cSpp-yabK8YvAt8H4mvRbAL0NOHV-MSZ8roDuGSBGI13EDzQlXI6fRqnpw4Tskk99vZeQh4iGxXtHVbOYOLTjdF7nTdrpPg4dTA30ptKd40-NSesqNsetrLe73ZyX03dvq0VHg69avFwOgztcVdrtd8PW3nc1s1eV6aTtWzrtpbbpt3J7UaTbJrDsK2xOZ5aeRJtTTMau7H2Om88j1UZdHc8NO2pstiTDeV2kLIYmbO9O1fc5foffRqDaGtrQgxPhGiiLVfKo2N3hvev66-8i2jc7xU3bvA8P3z8eL1risvPsEf_e_g6zfMdkMc0k4tVYttNMS4h74O8CHkZTZxSv1F-FvKSqa1_Pxb2_5KKQl6K0iDkpYj9PwAA__9nlKwr">