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

2024-11-11


1775. Undefined behavior of line splice in raw string literal

Section: 5.2  [lex.phases]     Status: C++14     Submitter: Canada     Date: 2013-09-24

N3690 comment CA 26

[Moved to DR at the February, 2014 meeting.]

According to phase 2 of 5.2 [lex.phases] paragraph 1,

Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. If, as a result, a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined.

There does not appear to be a good reason for the behavior to be undefined when the line splice occurs within a raw string literal, since the splicing will be reverted (5.4 [lex.pptoken] paragraph 3).

Proposed resolution (September, 2013):

Change 5.2 [lex.phases] paragraph 1 phase 2 as follows:

  1. Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. If, as a result, Except for splices reverted in a raw string literal, if a splice results in a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined. A source file that is not empty and that does not end in a new-line character, or that ends in a new-line character immediately preceded by a backslash character before any such splicing takes place, shall be processed as if an additional new-line character were appended to the file.