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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Improper casting of integer(2) selector for computed gotos
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          VijayKandiah
      </td>
    </tr>
</table>

<pre>
    Reproducer:

```
program test
    implicit none
    integer(2) :: ix
    
    ix = 1
    goto(10) ix
  10 continue
    print *, 'success'
    
end program test
```
```
$ flang test.f90 
flang: llvm-project/llvm/lib/IR/Instructions.cpp:3041: static CastInst *llvm::CastInst::Create(Instruction::CastOps, Value *, Type *, const Twine &, InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Changing the selector `ix`'s type to `integer(4)` works but using type `integer(2)` does not.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVE1v3DgM_TXyhdiBTH_M-OCDN-kAwS6wRVvkLsu0rdYjGRKVJv9-IXUmSXMsINji8-MD-ShZhWAWS9SL5m_R3Bcq8up8_2i-q5d_lJ2MWovRTS_9F9q9m6ImL6pByLxaeV1y2L1bvLoAU2AhBwAAc9k3ow2DdZZumGVayAs8ocAOklQ1gHm-fr6xnkFU91Bew8WxE3gqZUq5cksJ2lk2Nt6kd28sg8BB4B0IPIaoNYUg8PgmTnaCD5W-b-K3PdYwb8oumXiYO5kEMpJK3rany1-7d99Js8BzCtPLjALPD1_Swwb2UbNxNhz0votqqGRdptzAio2GOxU4sVLNOT-bcUOvkSfFJPD0Tu6N998eUrOPaot06_zby_661y7Jf_tpbILaBD3YQJ4_u2CyFHapoCEk0DgLopU6FRAe1WYmgSe3p6yvv5TzyJJOCwLxwT4lEqQEgaVAFHiEWZmNpoOQw-d_Pw1fP0GI48UwKBjjAp525xnYwcq8h9QKngWeF8NrHA_aXd6Z-bvFJoRIQeAZlJ3AWL3FiYBXAu1VWGFU-gd7penwcZJyuFuVXUya5UoQaCPNzqdmzXPi4DEAJ9_YZfD1kNbJoFbCT-d_BBgjQwxZJpv8nolX5uQogHWciiimvpq6qlMF9eWxqbuqrGVXrH03txr1NB7Hqi1P5bGZ6dShHFtdkValLkyPEht5Ksuybdq6O2isaS5P9XGSWLeVFrWkizLbIZl0cH4psj192VSykcWmRtpCvtOItzM7e2eZ7JQHdScQs28pau4L32e7x7gEUcvNBA5v2mx4y3-IX1LNPTxcdu928nn4yRE3f7zbrzbPzoN2lz0yTfkuhyL6rf_zA3Bt8qnH_wMAAP__35Rzug">