Is (--i == i++) an Undefined Behavior?

后端 未结 8 2025
离开以前
离开以前 2020-12-22 11:06

this question is related to my previous problem. The answer I got was \"It is an Undefined behavior.\"

Please anyone explain:

  • What is an undef
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 11:41

    What is an Undefined-Behaviour?

    It's quite simply any behaviour that is not specifically defined by the appropriate language specification. Some specs will list certain things as explicitly undefined, but really anything that's not described as being defined is undefined.

    how can I know my code has an undefined behavior?

    Hopefully your compiler will warn you - if that's not the case, you need to read the language specification and learn about all the funny corner cases and nooks & crannies that cause these sorts of problems.

    Be careful out there!

提交回复
热议问题