Why is a = i + i++ undefined and not unspecified behaviour

前端 未结 5 1664
误落风尘
误落风尘 2020-12-18 23:04

I read through several very good answers about undefined behaviour and sequence points (e.g. Undefined behavior and sequence points) and I understand, that

         


        
5条回答
  •  無奈伤痛
    2020-12-18 23:41

    There's a huge difference between undefined behavior and unspecified behavior. Unspecified behavior is well-formed (i.e., legal) but the standard leaves the compiler vendor some latitude as to implementation. Undefined behavior is an atrocity that appears to be syntactically correct. The primary reason for deeming behavior to be "undefined" rather than flat-out illegal (something the compiler must reject) is that sometimes that undefined behavior can be very hard to diagnose.

提交回复
热议问题