Why is calling non virtual member function on deleted pointer an undefined behavior?

后端 未结 4 934
醉话见心
醉话见心 2020-12-11 23:29

As, the title says:

Why is calling non virtual member function on deleted pointer an undefined behavior?

Note the

4条回答
  •  情话喂你
    2020-12-12 00:28

    Dereferencing of this in this case is effectively an implementation detail. I'm not saying that the this pointer is not defined by the standard, because it is, but from a semantically abstracted standpoint what is the purpose of allowing the use of objects that have been destroyed, just because there is a corner case in which in practice it will be "safe"? None. So it's not. No object exists, so you may not call a function on it.

提交回复
热议问题