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

            Bug ID: 100646
           Summary: gcc -E -fdirectives-only causes "error: unterminated
                    comment" when no new line at the end of file
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mtekieli+gcc at gmail dot com
  Target Milestone: ---

$ cat test_gcc11.cpp 
int main()
{
}
// namespace

$ g++ -E -fdirectives-only test_gcc11.cpp -o test_gcc11.o
test_gcc11.cpp:4:1: error: unterminated comment
    4 | // namespace
      | ^

Above error occurs when test_gcc11.cpp or anything included in test_gcc11.cpp
has a comment with no new line at the end of file.

It looks like this patch does not help:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=b6ecd493886891f8150905a2fd3b7d54e88fc7be

It worked fine with gcc 10.

Reply via email to