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

while 语句的条件不应为赋值表达式

9.3.3 ID_while_assignment
目录 › next › previous

虽然语言允许在 while 语句的条件中赋值,但 = 和 == 极易混淆,建议所有产生 bool 型结果的表达式,都不要包含赋值运算符。

本规则是 ID_assignmentAsSubExpression 的特化。

示例:

while (x = 123) { // Non-compliant
    ....
}

相关

ID_assignmentAsSubExpression

参考

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