Harden 64-bit to 32-bit casts to bad input