Crash in ASTContext::getTypeInfoImpl with uninitialised C23 auto variable and GNU asm register label
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Summary
Declaring an uninitialised variable with C23's `auto` and GNU's `asm` extension and register label results in a frontend crash when using the `gnu23` language standard. On an assertions-enabled build an assertion failure is seen before the crash.
This crash is present from Clang 18.1.0 to trunk. Clang with `-std=c23` instead of `-std=gnu23`, and GCC, both gracefully rejects this input.
Input generated by fuzzer.
### Revision
```
clang version 23.0.0git (https://github.com/llvm/llvm-project.git dd87edd1f48b02e4a58dbd0a6fdda07c36c4dea8)
Target: x86_64-unknown-linux-gnu
Build config: +assertions
```
### Reduced testcase
```c
auto register i asm("esp");
```
### Reproduction command
```bash
clang -std=gnu23 -fsyntax-only
```
### Observed behaviour
Clang aborts with the following assertion failure:
```
Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"' failed.
```
Triggered at:
```
clang/lib/AST/ASTContext.cpp:2542
```
Relevant stack frames:
```
clang::ASTContext::getTypeInfoImpl
clang::ASTContext::getTypeInfo
clang::Sema::CheckAsmLabel
clang::Sema::ActOnVariableDeclarator
```
Contributor guide
Research direction
Reproduce the crash with `clang -std=gnu23 -fsyntax-only` using the reduced testcase. Read `clang/lib/AST/ASTContext.cpp:2542` and the `Sema::CheckAsmLabel` and `Sema::ActOnVariableDeclarator` stack frames to trace the undeduced `auto` type. Done means this input is rejected gracefully without an assertion or frontend crash, while `-std=c23` behavior remains intact.
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