Does an expression with undefined behaviour that is never actually executed make a program erroneous?

前端 未结 9 953
情歌与酒
情歌与酒 2020-12-31 02:05

In many discussions about undefined behavior (UB), the point of view has been put forward that in the mere presence in a program of any construct that has UB in a p

9条回答
  •  轮回少年
    2020-12-31 02:45

    In the context of a safety-critical embedded system, the posted code would be considered defective:

    1. The code should not pass code review and/or standards compliance (MISRA, etc)
    2. Static analysis (lint, cppcheck, etc) should flag this as a defect
    3. Some compilers can flag this as a warning (implying a defect, as well.)

提交回复
热议问题