What's the difference between “dead code” and “unreachable code”?

后端 未结 4 2225
野性不改
野性不改 2021-02-18 22:52

I thought those terms where synonymous, but a note in MISRA regarding dead code indicates this to be wrong? What\'s the difference? Is one a subset of the other?

4条回答
  •  自闭症患者
    2021-02-18 23:19

    Dead Code

    Code that performs functions that have no effect. Basically stuff that wouldn't make a difference if removed.

    Unreachable Code

    Code that due to other logic will never be executed. This is usually the sign of an error.

提交回复
热议问题