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

后端 未结 4 2218
野性不改
野性不改 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:05

    unreachable code is something that would never be executed because there is no flow control to reach the code.

    A dead code is something that gets (or might get) executed, but its results are never used.

提交回复
热议问题