https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102321
Bug ID: 102321 Summary: A partial comment at the end of file should be ill-formed Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xmh970252187 at gmail dot com Target Milestone: --- Example 1 ```` int main(){ } //\ ```` Consider the first example, it is rejected by GCC since the sequence of the backslash followed by new-line characters is deleted, which results in a partial comment at the end of the source file. It violates > A source file shall not end in a partial preprocessing token or in a partial > comment. However, a variant example has an inconsistent treatment ```` int main(){ } //\ ```` In this example, the character "\" is not followed by a new-line and the source file ends with it. According to [lex.phases] p2 > A source file that is not empty and that does not end in a new-line > character, or that ends in a splice, shall be processed as if an additional > new-line character were appended to the file. That means the second example is identical to the first one, after this processing. However, the second example is accepted by GCC. It should be ill-formed too.