[llvm-bugs] [Bug 51844] New: The partial comment produced by deleting splice is accepted by Clang

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 14 02:40:59 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51844

            Bug ID: 51844
           Summary: The partial comment produced by deleting splice is
                    accepted by Clang
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xmh970252187 at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Given the source file: 
````
int main(){
}
//\

````
According to [lex.phases] p2

> Each sequence of a backslash character (\) immediately followed by zero or more whitespace characters other than new-line followed by a new-line character is deleted, splicing physical source lines to form logical source lines.

That means the source file will end with `/`, after the above phase. "//"
starts a comment and the comment is terminated by a new-line as per
[lex.comment] p1

> The characters // start a comment, which terminates immediately before the next new-line character.  

According to [lex.phases] p3  
> A source file shall not end in a partial preprocessing token or in a partial comment.

Since there is no new-line to terminate the comment, hence it is a partial
comment and the source file ends with that partial comment, the program should
be ill-formed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210914/da81773b/attachment.html>


More information about the llvm-bugs mailing list