On Undefined Behavior

前端 未结 7 2166
盖世英雄少女心
盖世英雄少女心 2021-01-02 04:14

Generally, UB is regarded as being something that has to be avoided, and the current C standard itself lists quite a few examples in appendix J.

However, there are c

7条回答
  •  暖寄归人
    2021-01-02 04:43

    In general, it's better to completely avoid it. On the other hand, if your compiler documentation explicitly states that that specific thing that is UB for the standard is instead defined for that compiler, you may exploit it, possibly adding some #ifdef/#error machinery to block the compilation in case another compiler is used.

提交回复
热议问题