This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::codecvt on character ranges are in a possibly unintended formSection: 28.3.4.2.5.3 [locale.codecvt.virtuals] Status: New Submitter: Jiang An Opened: 2026-06-01 Last modified: 2026-06-13
Priority: Not Prioritized
View other active issues in [locale.codecvt.virtuals].
View all other issues in [locale.codecvt.virtuals].
View all issues with New status.
Discussion:
Currently, some preconditions in 28.3.4.2.5.3 [locale.codecvt.virtuals] require that
"first <= last is well-defined and true", where first
and last are pointer parameters that are intended to denote a range. These
preconditions seem specified too relaxedly, and make some necessary preconditions implicitly specified
in Effects. Per 7.6.9 [expr.rel], comparing pointers that are not associated with the
same storage instance still has well-defined behavior although the result is unspecified. And even
if the result is specified to be true, it's possible for first and last
to point to elements of different array subobjects in the same complete object, which renders
last not reachable from first.
Proposed resolution:
This wording is relative to N5046.
Modify 28.3.4.2.5.3 [locale.codecvt.virtuals] as indicated:
result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next, externT* to, externT* to_end, externT*& to_next) const; result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next, internT* to, internT* to_end, internT*& to_next) const;-1- Preconditions:
[…](from <= from_end && to <= to_end)is well-defined andtrue[from, from_end)and[to, to_end)are both valid ranges;stateis initialized, if at the beginning of a sequence, or else is equal to the result of converting the preceding characters in the sequence.result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;[…]-7- Preconditions:
[…](to <= to_end)is well-defined andtrue[to, to_end)is a valid range;stateis initialized, if at the beginning of a sequence, or else is equal to the result of converting the preceding characters in the sequence.int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;-12- Preconditions:
[…](from <= from_end)is well-defined andtrue[from, from_end)is a valid range;stateis initialized, if at the beginning of a sequence, or else is equal to the result of converting the preceding characters in the sequence.