[clang][Windows] Crash in ASTContext::getDeclaratorForUnnamedTagDecl when compiling C code with -fsanitize=function on Windows
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
When compiling C code that uses anonymous structs inside `typeof` (or as return types) with `-fsanitize=function` or `-fsanitize=undefined` targeting the Microsoft ABI, clang crashes with a null pointer dereference.
**Reproduction:**
Create a file `repro.c` with the following code:
```C
static struct { int first; float second; } sample_tuple(void) {
return (typeof(sample_tuple())){ .first = 10, .second = 0.1f };
}
```
Compile with:
```bash
clang-cl -fsanitize=function -c repro.c
```
**Environment:**
- Clang Version: Tested on 22.1.8 and upstream 24.0.0
- Target: x86_64-pc-windows-msvc (Microsoft ABI)
Contributor guide
Research direction
Start with the repro.c example and run clang-cl -fsanitize=function -c repro.c for the Microsoft ABI target. Then inspect ASTContext::getDeclaratorForUnnamedTagDecl, focusing on the null pointer dereference reported for anonymous structs in typeof or return types. Done means the reproducer no longer crashes under the stated sanitizer options.
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
- Clearly specified
- Newbie friendliness
- 48/100