Title
detection of invalid mbstate_t in codecvt
Status
cd1
Section
[locale.codecvt.byname]
Submitter
Martin Sebor

Created on 2002-09-06.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The intent is that implementations should not be required to detect invalid state values; such a requirement appears nowhere else. An invalid state value is a precondition violation, i.e. undefined behavior. Implementations that do choose to detect invalid state values, or that choose to detect any other kind of error, may return error as an indication.

Date: 2010-10-21.18:28:33

Proposed resolution:

Add a new paragraph before 22.2.1.5.2, p5, and after the function declaration below

    result do_unshift(stateT& state,
    externT* to, externT* to_limit, externT*& to_next) const;

as follows:

    Requires: (to <= to_end) well defined and true; state initialized,
    if at the beginning of a sequence, or else equal to the result of
    converting the preceding characters in the sequence.

and change the text in Table 54, row 4, the error row, under the heading Meaning, from

    state has invalid value

to

    an unspecified error has occurred
Date: 2002-09-06.00:00:00

All but one codecvt member functions that take a state_type argument list as one of their preconditions that the state_type argument have a valid value. However, according to 22.2.1.5.2, p6, codecvt::do_unshift() is the only codecvt member that is supposed to return error if the state_type object is invalid.

It seems to me that the treatment of state_type by all codecvt member functions should be the same and the current requirements should be changed. Since the detection of invalid state_type values may be difficult in general or computationally expensive in some specific cases, I propose the following:

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2418
2010-10-21 18:28:33adminsetmessages: + msg2417
2002-09-06 00:00:00admincreate