Wording for “Remove undefined behavior for mismatched quote characters”

2026-10-19

Preamble

Contributors

Ryan Karl (rational, history)

Ryan Karl, Corentin Jabot, Jens Gustedt (wording)

number Title Authors Remarks
n3992 this paper Wording Group
n3806 Remove undefined behavior for mismatched quote characters Ryan Karl rationale
N3886 Working Draft base for diff, 2026-06-26

Relevant polls

Forward to the Wording Group

meeting date for against abstain
Ottawa 2026-08 unanymous

LaTeX document branch

none

Liaison

none

Wording choices

We avoid the ambiguity that was present in N3806 about ' characters that could appear in other constructs (in particular numbers) by insisting that the quote characters shall not be a single-character preprocessing token on their own.

Legend for the wording

Deletions in the shown standard text are as shown here, additions as shown here, code snippets as here. These may be rendered differently according to the style in which the document is shown by your browser but should always be well distinguishable. In the style provided there are two visual distinctions:

Close to each other proposed changes resemble like this.

Proposed wording

In 6.4.1 change

6.4 Lexical elements

6.4.1 General

…

2 Each preprocessing token that is converted to a token shall have the lexical form of a keyword, an identifier, a constant, a string literal, or a punctuator. A preprocessing token that consists of a single universal character name shall match one of the other preprocessing token categories. If a preprocessing token consists of a single character, that character shall not be a ' or " character.

Semantics

3 A token is the minimal lexical element of the language in translation phases 7 and 8 (5.2.1.2). The categories of tokens are: keywords, identifiers, constants, string literals, and punctuators. A preprocessing token is the minimal lexical element of the language in translation phases 3 through 6. The categories of preprocessing tokens are: header names, identifiers, preprocessing numbers, character literals, string literals, punctuators, and both single universal character names as well as single non-white-space characters that do not lexically match the other preprocessing token categories.45) If a ’ or a " character matches the last category, the behavior is undefined. Preprocessing tokens can be separated by white space; this consists of comments (described later), or white-space characters (space, horizontal tab, new-line, vertical tab, and form-feed), or both. As described in 6.10, in certain circumstances during translation phase 4, white space (or the absence thereof) serves as more than preprocessing token separation. White space may appear within a preprocessing token only as part of a header name or between the quotation characters in a character literal or string literal.

Remove from “J.2 Undefined behavior”

(19) An unmatched ’ or " character is encountered on a logical source line during tokenization (6.4).