<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120042>120042</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when two arguments of transfer intrinsic function have different kind type parameters
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang : 20.0.0(2b129dacdde667137b5012d52f1d96e0ab26c749)/AArch64
```

When building [bigdft-chess Version 1.9.5](https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.5/bigdft-suite-1.9.5.tar.gz), a compilation error occurs.  
When two arguments (`source` and `mold`) of `transfer` intrinsic function have different `kind type parameters`, a compilation error occurs.  
Even if the `types` are the same or different, if the `kind type parameters` are the same (for example, kind=4 and kind=4), a compilation terminates normally, and if they are different (for example, kind=4 and kind=8), a compilation error occurs.  


The following are the test program, Flang, Gfortran and ifx compilation/execution result.

test_2.f90:
```fortran
program main
  integer(4), dimension(5) :: int_array
  real(8), dimension(5) :: real_array
  int_array = (/ 1, 2, 3, 4, 5 /)
  real_array = transfer(int_array, real_array)
  write(6,*) "real_array = ", real_array
end program main
```

```
$ flang test_2.f90
error: Semantic errors in test_2.f90
./test_2.f90:5:3: error: Dimension 1 of left-hand side has extent 5, but right-hand side has extent 3
    real_array = transfer(int_array, real_array)
 ^^^^^^^^^^
$
```

```
$ gfortran test_2.f90; ./a.out
 real_array = 4.2439915824246103E-314   8.4879831653432862E-314   2.4703282292062327E-323 3.4767205879998127E-310   3.4767205879660186E-310
$
```

```
$ ifx test_2.f90; ./a.out
 real_array =   4.243991582424610E-314 8.487983165343286E-314
  2.470328229206233E-323  0.000000000000000E+000 0.000000000000000E+000
$
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVt1y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