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

后端 未结 7 860
旧时难觅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:24

    There is no compiler mentioned in the standard and implementation details are up to the vendors.

    The standard defines how code should behave (in a syntactical and semantical way) and/or be constrained in complexity terms regarding some standard library algorithms. The source code doesn't have to have a precise behavior (nor this is defined anywhere). Every compiler just has to produce code that, under the as-if rule, is correct.

    It doesn't make sense to refer to undefined behavior of the compiler

提交回复
热议问题