Movatterモバイル変換


[0]ホーム

URL:


Issue 312 - WG21 CWG Issues
Title
“use” of invalid pointer value not defined
Status
cd3
Section
6.8.6.5.3 [basic.stc.dynamic.deallocation]
Submitter
Martin von Loewis

Created on2001-09-20.00:00:00 last changed145 months ago

Messages

msg4372 (view)
Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

msg3498 (view)
Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

This issue is resolved by the resolution ofissue 616.

msg569 (view)
Date: 2020-12-15.00:00:00

6.8.6.5.3 [basic.stc.dynamic.deallocation] paragraph 4 mentions that the effectof using an invalid pointer value is undefined. However, the standardnever says what it means to 'use' a value.

There are a number of possible interpretations, but it appears thateach of them leads to undesired conclusions:

  1. A value is 'used' in a program if a variable holding this valueappears in an expression that is evaluated.This interpretation would render the sequence
       int *x = new int(0);   delete x;   x = 0;
    into undefined behaviour. As this is a common idiom, this isclearly undesirable.
  2. A value is 'used' if an expression evaluates to that value.This would render the sequence
       int *x = new int(0);   delete x;   x->~int();
    into undefined behaviour; according to _N4778_.7.6.1.4 [expr.pseudo],the variable x is'evaluated' as part of evaluating the pseudo destructor call. This,in turn, would mean that all containers (Clause 23 [containers])of pointers showundefined behaviour, e.g. 23.3.11.4 [list.modifiers]requires to invoke thedestructor as part of theclear() method of the container.

If any other meaning was intended for 'using an expression', thatmeaning should be stated explicitly.

(See alsoissue 623.)

History
DateUserActionArgs
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: +msg4372
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetstatus: review -> ready
2011-09-06 00:00:00adminsetmessages: +msg3498
2011-09-06 00:00:00adminsetstatus: open -> review
2001-09-20 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp