C++ Logo


Advanced search

Re: [SG16] On whitespaces and new-line

From: Tom Honermann <tom_at_[hidden]>
Date: Fri, 26 Mar 2021 00:31:58 -0400
On 3/25/21 4:46 PM, Steve Downey wrote:
> On Thu, Mar 25, 2021 at 4:34 PM Tom Honermann <tom_at_[hidden]
> <mailto:tom_at_[hidden]>> wrote:
> There are two CWG issues related to this:
> * CWG #1655: Line endings in raw string literals
> <https://wg21.link/cwg1655>
> It looks like the current text addresses this. From 1655 "Is it
> intended that, for example, a CRLF in the source of a raw string
> literal is to be represented as a newline character or as the original
> characters?"
> From the current draft: http://eel.is/c++draft/lex.string#4
> [/Note 2 <http://eel.is/c++draft/full#lex.string-note-2>/:
> A source-file new-line in a raw string literal results in a new-line
> in the resulting execution string literal.
> <http://eel.is/c++draft/full#lex.string-4.sentence-1>
> Assuming no whitespace at the beginning of lines in the following
> example, the assert will succeed:const char* p = R"(a\ b c)";
> assert(std::strcmp(p, "a\\\nb\nc") == 0);
> — /end note/]

It does look that way, but this wording also predates the core issue.
Perhaps that wording went unnoticed when the issue was recorded. I did
some brief tests and, assuming I didn't mess it up, it looks like the
assert passes for gcc (9.1), Clang (7.0), and Visual C++ (2019 16.7)
when presented a source file with CRLF line endings. Perhaps this issue
can be resolved as NAD. I sent a message to CWG.


Received on 2021-03-25 23:32:01