36. Iword & pword storage lifetime omitted

Section: 30.5.3.5 [ios.base.storage] Status: TC1 Submitter: Nathan Myers Opened: 1998-08-06 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [ios.base.storage].

View all issues with TC1 status.

Discussion:

In the definitions for ios_base::iword and pword, the lifetime of the storage is specified badly, so that an implementation which only keeps the last value stored appears to conform. In particular, it says:

The reference returned may become invalid after another call to the object's iword member with a different index ...

This is not idle speculation; at least one implementation was done this way.

Proposed resolution:

Add in 30.5.3.5 [ios.base.storage], in both paragraph 2 and also in paragraph 4, replace the sentence:

The reference returned may become invalid after another call to the object's iword [pword] member with a different index, after a call to its copyfmt member, or when the object is destroyed.

with:

The reference returned is invalid after any other operations on the object. However, the value of the storage referred to is retained, so that until the next call to copyfmt, calling iword [pword] with the same index yields another reference to the same value.

substituting "iword" or "pword" as appropriate.