Is something undefined behavior by omission?

后端 未结 3 539
-上瘾入骨i
-上瘾入骨i 2021-01-18 07:22

The standard says:

1.3.24                                                          [defns.undefined]
undefined behavior         


        
3条回答
  •  滥情空心
    2021-01-18 07:49

    Formally, anything which the standard doesn't define is undefined behavior. How is it defined, if the standard doesn't define it?

    Practically, there are a couple of things which are taken as given; if the standard defines a behavior, for example, an implementation cannot add additional observable behavior. (I.e. in a statement like a = 2 * a;, an implementation isn't allowed to modify anything but a, even though I don't think you'll find an explicit passage to this effect in the standard.)

    But that's about it. If the standard doesn't define it, it's undefined behavior according to the standard. (An implementation may provide further definitions. In fact, all do.)

提交回复
热议问题