Newline in raw string literals blow up macro expansion
Issue
A raw string literal should become a single pptoken before macros are expanded. GCC seems to disagree:
$ g++ --version
g++ (GCC) 4.7.0 20120507 (Red Hat 4.7.0-5)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rpm -qf `which g++`
devtoolset-1.0-gcc-c++-4.7.0-5.3.el5
$ cat raw_string_literal.cpp
#define STR(lit) lit
const char x[] = R"(
x)";
const char y[] = STR(R"(
x)");
$ g++ -std=c++11 raw_string_literal.cpp
raw_string_literal.cpp:5:22: error: unterminated raw string
raw_string_literal.cpp:5:1: error: stray 'R' in program
raw_string_literal.cpp:6:3: warning: missing terminating " character [enabled by default]
raw_string_literal.cpp:5:1: error: missing terminating " character
raw_string_literal.cpp:5:18: error: initializer fails to determine size of 'y'
raw_string_literal.cpp:5:18: error: expected ',' or ';' at end of input
Environment
- Red Hat Developer Toolset 1.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
