Is the behaviour of the compiler undefined, with Undefined Behaviour?

后端 未结 7 762
旧时难觅i
旧时难觅i 2021-01-03 08:48

When I answered this question, I wrote:

First, it is important to note that it is not only the behaviour of the user program that is undefined, it is

7条回答
  •  有刺的猬
    2021-01-03 09:10

    If a code has undefined behaviour it means that the standards does not know how to handle such thing. Thus it can give any output. I think it doesn't have to do with compiler as it doesn't make sense. It makes sense that it has to be the implementation that works according to standards.

    So, if standards don't know how to handle such code, then how can compilers give a defined output?

提交回复
热议问题