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

异或运算符左右子表达式不应相同

10.3.7 ID_selfExclusiveOr
目录 › next › previous

与自身异或的结果总为 0。

示例:

a = a ^ a;   // Non-compliant

这种代码可能是为了对变量清零,也可能是笔误,即使没有逻辑错误,也应将变量直接赋值为 0 以提高可读性。

参考

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