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

            Bug ID: 88475
           Summary: -E -fdirectives-only clashes with raw strings
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

Source:
$ cat test.cpp
extern const char str[] = R"( 
#define FOO 1
#NOSORT
)";

Compiles just fine:
$ g++ -c test.cpp; echo $?                
0

Preprocessed output looks correct:
$ g++ -E test.cpp         
# 1 "test.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "test.cpp"
extern const char str[] = R"( 
#define FOO 1
#NOSORT
)";

But in the presence of -fdirectives-only (which icecream uses), it produces an
error and incorrectly preprocesses:
$ g++ -E -fdirectives-only test.cpp | tail -5
test.cpp:3:2: error: invalid preprocessing directive #NOSORT
 #NOSORT
  ^~~~~~
# 1 "test.cpp"
extern const char str[] = R"( 
#define FOO 1

)";

According to strace, cc1plus is the preprocessor, not /lib/cpp.

Reply via email to