Title
Clarify moved-from objects are "toxic"
Status
nad
Section
[utility.arg.requirements]
Submitter
INCITS

Created on 2010-08-25.00:00:00 last changed 166 months ago

Messages

Date: 2011-02-25.15:54:31

Proposed resolution:

Resolved by N3241

Date: 2010-10-24.22:33:31

[ Resolution proposed in ballot comment ]

State as a general requirement that moved-from objects can be destroyed and can be the destination of an assignment. Any other use is undefined behavior.

Date: 2010-10-24.22:33:31

Addresses US-85

20.2.1 Table 34 "MoveConstructible requirements" says "Note: rv remains a valid object. Its state is unspecified". Some components give stronger guarantees. For example, moved-from shared_ptrs are guaranteed empty (20.9.11.2.1/25). In general, what the standard really should say (preferably as a global blanket statement) is that moved-from objects can be destroyed and can be the destination of an assignment. Anything else is radioactive. For example, containers can be "emptier than empty". This needs to be explicit and required generally.

Note: The last time that one of us mentioned "emptier than empty" (i.e. containers missing sentinel nodes, etc.) the objection was that containers can store sentinel nodes inside themselves in order to avoid dynamically allocating them. This is unacceptable because

(a) it forces existing implementations (i.e. Dinkumware's, Microsoft's, IBM's, etc.) to change for no good reason (i.e. permitting more operations on moved-from objects), and

(b) it invalidates end-iterators when swapping containers. (The Working Paper currently permits end-iterator invalidation, which we consider to be wrong, but that's a separate argument. In any event, mandating end-iterator invalidation is very different from permitting it.)

History
Date User Action Args
2011-03-22 08:05:22adminsetstatus: open -> nad
2011-02-25 15:54:31adminsetmessages: + msg5547
2010-10-24 22:33:31adminsetmessages: + msg5078
2010-08-25 00:00:00admincreate