Observable behavior and undefined behavior — What happens if I don't call a destructor?

后端 未结 13 2691
滥情空心
滥情空心 2020-12-03 06:48

Note: I\'ve seen similar questions, but none of the answers are precise enough, so I\'m asking this myself.

This is a very nitpicky "language-lawye

13条回答
  •  生来不讨喜
    2020-12-03 07:49

    This exact issue with the wording is the subject of editorial pull request against the draft C++ standard [basic.life] Remove description of impossible UB which seeks to strike this wording from the draft standard:

    A destructor that is not called cannot produce side effects, therefore it is impossible to depend on those side effects.

    After much discussion it seemed to lean towards that direction:

    Editorial meeting: The standard rules cannot depend on the programmer's intent. Pass to CWG with the intent of applying as-is.

    but it needs to be reviewed by the Core Working Group (CWG) first and is therefore not an editorial change. I believe this means it will eventually show up as a defect report.

    So in conclusion this looks like an open issue as to whether that wording has any meaning at all but it will be reviewied by CWG eventually.

提交回复
热议问题