This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


2579. Undefined behavior when token pasting does not create a preprocessing token

Section: 15.6.4  [cpp.concat]     Status: open     Submitter: US     Date: 2019-10-23     Liaison: SG12

(From National Body comment US 143 on the C++20 DIS.)

Subclause 15.6.4 [cpp.concat] paragraph 3 specifies:

If the result begins with a sequence matching the syntax of universal-character-name, the behavior is undefined. [Note: ... --end note] If the result is not a valid preprocessing token, the behavior is undefined.

Undefined behavior during lexing is not acceptable. The behavior ought to be well-defined, ill-formed, or conditionally-supported.

Additional notes (January, 2023):

Forwarded to SG12 with paper issue 1410, by decision of the CWG and SG12 chairs.

Additional notes (November, 2023):

The first case of undefined behavior was addressed by paper P2621R2 (Undefined behavior in the lexer), adopted in June, 2023. The relevant part of 15.6.4 [cpp.concat] paragraph 3 now reads:

... [Note 1: Concatenation can form a universal-character-name (5.3 [lex.charset]). —end note] If the result is not a valid preprocessing token, the behavior is undefined. ...