☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

对有符号整数进行超出取值范围的左移运算

C++-Undefined-Behavior-48
目录 › next › previous

将符号位移出相关比特位,或将非符号位移入符号位,在数学上是没有意义的。

示例:

int b = -1 << 1;    // Undefined

编译器可能会用乘法或除法实现有符号整数的移位,但不属于标准行为。

依据

ISO/IEC 14882:2011 5.8(2)-undefined

规则

ID_bitwiseOperOnSigned
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.