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

不应存在不受条件控制的跳转语句

9.7.5 ID_uncondJump
目录 › next › previous

不受条件控制的跳转语句会剥夺其后续代码的执行机会,往往意味着逻辑错误,也可能是调试或维护痕迹。

示例:

void foo() {
    if (cond) {
        goto L;   // Non-compliant, unconditional goto
        bar();    // Unreachable code
    }
L:
    ....
}

例中 goto 语句相对其同一作用域中的后续代码 bar(); 是不受条件控制的,bar 函数得不到执行机会。

相关

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