About undefined shift and integer overflow issues (cherry picked from commit 30b34d883dc099fbe68fe522bedbacc09c74eda6)