Title
Missing restrictions imposed by __STDC_MB_MIGHT_NEQ_WC__
Status
tentatively ready
Section
5.3.1 [lex.charset]
Submitter
Jay Ghiron

Created on 2026-10-05.00:00:00 last changed 2 weeks ago

Messages

Date: 2026-10-07.20:41:18

Proposed resolution (approved by CWG 2026-10-06):

  1. Change in 5.3.1 [lex.charset] paragraph 5 as follows:

    A literal encoding or a locale-specific encoding of one of the execution character sets (16.3.3.3.4 [character.seq]) encodes each element of the basic literal character set as a single code unit with non-negative value, distinct from the code unit for any other such element.

    [Note 3: A character not in the basic literal character set can be encoded with more than one code unit; the value of such a code unit can be the same as that of a code unit for an element of the basic literal character set. —end note]

    If the implementation does not define the preprocessor macro __STDC_MB_MIGHT_NEQ_WC__ (15.12 [cpp.predefined]), each element of the basic character set has the same code unit value in the ordinary literal encoding and the wide literal encoding.

    The u+0000 null character is encoded as the value 0. No other element of the translation character set is encoded with a code unit of value 0. The code unit value of each decimal digit character after the digit 0 (u+0030) is one greater than the value of the previous. The ordinary and wide literal encodings are otherwise implementation-defined. For a UTF-8, UTF-16, or UTF-32 literal, the implementation shall encode the Unicode scalar value corresponding to each character of the translation character set as specified in the Unicode Standard for the respective Unicode encoding form.

  2. Change in 15.12 [cpp.predefined] paragraph 2 as follows:

    ...

    __STDC_MB_MIGHT_NEQ_WC__

    The integer literal 1, intended to indicate that, in the encoding for wchar_t, a member of the basic character set need not have a code value equal to its value when used as the lone character in an ordinary character literal (5.3.1 [lex.charset]).

    ...
Date: 2026-10-05.00:00:00

(From submission #1017.)

Subclause 15.12 [cpp.predefined] specifies __STDC_MB_MIGHT_NEQ_WC__, but there are no normative rules elsewhere in the standard tied to its presence or absence.

In contrast, C2y specifies in its subclause 7.22.1 for wchar_t:

  wchar_t
which is an integer type whose range of values can represent codes (or part of a sequence of codes) for all the members of the supported wide execution and wide literal encodings (6.2.9); the null character shall have the code value zero. Each member of the basic character set shall have a code value equal to its value when used as the lone character in an ordinary character literal if an implementation does not define __STDC_MB_MIGHT_NEQ_WC__; and,
History
Date User Action Args
2026-10-07 20:41:18adminsetstatus: open -> tentatively ready
2026-10-05 18:31:19adminsetmessages: + msg8695
2026-10-05 00:00:00admincreate