<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108832>108832</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Flang is unable to compile a code with a call to `transfer`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
inaki-amatria
</td>
</tr>
</table>
<pre>
- `flang-new` version is: `flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git bafe3a4b0ca0e9294a18a9ec4fea8567cb98dabe)`
- Reduced test case:
```f90
! main.f90
program main
use iso_fortran_env, only : real32, int32
real(kind=real32) :: mask_val
integer(kind=int32), dimension(2) :: i4tmp
i4tmp = transfer(mask_val, i4tmp)
end program main
```
- `flang-new` invocation is: `flang-new main.f90`
- Expected behavior is: The code compiles successfully without errors. According to https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/TRANSFER.html: "If the bitwise representation of the result is longer than that of SOURCE, then the leading bits of the result correspond to those of SOURCE and any trailing bits are filled arbitrarily."
- Actual behavior: Compilation fails with the following error:
```
error: Semantic errors in main.f90
main.f90:5:3: error: Dimension 1 of left-hand side has extent 2, but right-hand side has extent 1
i4tmp = transfer(mask_val, i4tmp)
^^^^^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v4zYQ_TXUZWCBoj5iHXRw1zHQSwsk23MwIkcSG4o0SMrZ_PuCsq00WexhAUEfnHlPfG9miCHo0RJ1rP6D1ccMlzg532mLr3qHM0avMeudeu92wBo-GLTjztIbazhcyAftLOjAysOn6BYSPOc5H3UEJvZTjOeUysSJidOo47T0uXQzEydjLvfH7uzdvyRjnlA9DlRi1XOJnFrRVljssSVZDYT7unmQfbtX2BMTLWs440fGDzt4IrVIUhApRJAYKP10jaWk9RraWzYTBcyobb6tnL0bPc7r6nUFYAkEOriXwfno0b6QvTDxDZw175DEe0JTirSkb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