https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91412

            Bug ID: 91412
           Summary: Unexpectedly correct raw string literal
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alisdairm at me dot com
  Target Milestone: ---

Per several existing bug reports (e.g.,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38433) in phase one of
translation, when mapping source character set to basic character set, a '\'
character followed by trailing whitespace until the newline is mapped to a
single '\' character and the newline.  Therefore, comments with what the author
believes to be significant trailing whitespace (e.g., to preserve ASCII art in
documentation) is mapped into a line-continuation in a comment, potentially
swallowing code in the following line.

So far, so good.

However, the following program does not follow that same mapping:

#include <iostream>

int main() {
   std::cout << R"(Hello\   
World!)";
}

(note that there are 3 space characters after the '\' that may get swallowed by
HTML/bugzilla)

In this case, the line-splice for '\' occurs in phase 2 of translation, and
then gets undone in phase 7.  However, this does not undo the source-to-basic
character mapping in phase 1, only the splicing of a '\' immediately followed
by a newline, so there should be no whitespace following 'Hello' in the emitted
output.  Yet when the program is compiled and run, three space characters are
indeed present.


Either the source-to-basic-character set mapping needs updating to further
special case trailing whitespace in what will later be determined to be a raw
string literal, or the raw literal should not contain the three spaces.

Reply via email to