[clang-tidy] Multiple checks crash on invalid initialization of a struct
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following header file causes clang-tidy 23.1.0 to crash:
```cpp
struct A {
int a1;
};
struct B : A {
B(const A& a);
};
struct C {
A a;
B b;
};
struct D {
C c;
};
inline D d{0, {0}};
```
```
Stack dump:
0. ASTMatcher: Processing 'readability-trailing-comma' against:
InitListExpr :
--- Bound Nodes Begin ---
initlist - { InitListExpr : }
--- Bound Nodes End ---
Signalled during AST worker action: Build AST
Filename: d:\Projects\Kosmonavt\include\test.hpp
Directory: D:/Projects/Kosmonavt/build
Command Line: D:\System\LLVM\bin\clang++.exe --driver-mode=g++ -D_MBCS -ID:/Projects/Kosmonavt/include -ID:/Projects/Kosmonavt/build -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -c -std=gnu++23 -resource-dir=D:\System\LLVM\lib\clang\23 -- d:\Projects\Kosmonavt\include\test.hpp
Version: 1
Exception Code: 0xC0000005
```
Adding `readability-trailing-comma` to `.clang-tidy` results in `modernize-use-designated-initializers` crashing instead.
Contributor guide
Research direction
Reproduce the crash with the supplied C++ header as test.hpp using clang-tidy 23.1.0 and the readability-trailing-comma check, then compare behavior when modernize-use-designated-initializers is enabled. Trace the AST worker action and the reported InitListExpr; done means both checks process this invalid initialization without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100