llvm / llvm/llvm-project

Parsing of `#line` preprocessor directive is wrong when `\\` is present in the filename argument

Open
#213,973 9 comments 0 reactions 0 assignees View on GitHub
clang:frontend diverges-from:edg diverges-from:gcc diverges-from:msvc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c
#include

int main() {
#line 10 "not_a_\\tab"
const char *actual = __FILE__;
const char *expected = "not_a_\\tab";

return strcmp(actual, expected);
}
```
The string comparison should return 0, but it returns a non-zero value.

Contributor guide

Open the contributing guide

Research direction

Start by compiling and running the supplied C reproducer, focusing on how the #line filename argument containing \\ is parsed and used for __FILE__. Trace that preprocessor path to identify the incorrect handling, then verify that the comparison returns zero and add a regression test if the existing test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.