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.