Clang 22 Crash: Concept as template argument
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
i'm trying to make a template class that takes in a concept as a template argument (rather than a type), but it crashes on every version i ever downloaded, latest of which is Clang 22.1.3, while in the meantime, the same idea of passing concepts as template arguments works when passed to other concepts (higher order meta programming).
below is the simplest ever of such case where the build messages are as follows:
```c++
template concept Constraint>
class TConstrained {};
template
concept FooLike = requires (T& SomeObject) {
SomeObject.Foo();
};
int main() {
auto ConstrainedFoo = TConstrained ();
return 0;
}
```
Build messages:
```
====================[ Build | ClangReport | Debug ]=============================
"C:\Program Files\JetBrains\CLion 2026.1\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\Fadya\CLionProjects\ClangReport\cmake-build-debug --target ClangReport -j 14
[1/2] Building CXX object CMakeFiles/ClangReport.dir/main.cpp.obj
FAILED: [code=1] CMakeFiles/ClangReport.dir/main.cpp.obj
C:\PROGRA~1\LLVM\bin\clang++.exe -D_MBCS -O0 -std=gnu++26 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -MD -MT CMakeFiles/ClangReport.dir/main.cpp.obj -MF CMakeFiles\ClangReport.dir\main.cpp.obj.d @CMakeFiles\ClangReport.dir\main.cpp.obj.modmap -o CMakeFiles/ClangReport.dir/main.cpp.obj -c C:/Users/Fadya/CLionProjects/ClangReport/main.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: C:\\PROGRA~1\\LLVM\\bin\\clang++.exe -D_MBCS -O0 -std=gnu++26 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -MD -MT CMakeFiles/ClangReport.dir/main.cpp.obj -MF CMakeFiles\\ClangReport.dir\\main.cpp.obj.d @CMakeFiles\\ClangReport.dir\\main.cpp.obj.modmap -o CMakeFiles/ClangReport.dir/main.cpp.obj -c C:/Users/Fadya/CLionProjects/ClangReport/main.cpp
1. parser at end of file
2. C:/Users/Fadya/CLionProjects/ClangReport/main.cpp:9:5: LLVM IR generation of declaration 'main'
3. C:/Users/Fadya/CLionProjects/ClangReport/main.cpp:9:5: Generating code for declaration 'main'
Exception Code: 0xC0000005
#0 0x00007ff7cdabebab (C:\PROGRA~1\LLVM\bin\clang++.exe+0x177ebab)
#1 0x00007ff7cdabdf2d (C:\PROGRA~1\LLVM\bin\clang++.exe+0x177df2d)
#2 0x00007ff7cdac7df1 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x1787df1)
#3 0x00007ff7cdabf353 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x177f353)
#4 0x00007ff7cdabdf2d (C:\PROGRA~1\LLVM\bin\clang++.exe+0x177df2d)
#5 0x00007ff7cdabae6f (C:\PROGRA~1\LLVM\bin\clang++.exe+0x177ae6f)
#6 0x00007ff7ccd69ed5 (C:\PROGRA~1\LLVM\bin\clang++.exe+0xa29ed5)
#7 0x00007ff7ceb04892 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27c4892)
#8 0x00007ff7ceb0f348 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27cf348)
#9 0x00007ff7ceb0b71d (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27cb71d)
#10 0x00007ff7ceb0b08e (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27cb08e)
#11 0x00007ff7ceb0b5fa (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27cb5fa)
#12 0x00007ff7ceb0089b (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27c089b)
#13 0x00007ff7ceb1324e (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27d324e)
#14 0x00007ff7ceb14685 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x27d4685)
#15 0x00007ff7cd5e7233 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x12a7233)
#16 0x00007ff7cc3456f0 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x56f0)
#17 0x00007ff7cc34523e (C:\PROGRA~1\LLVM\bin\clang++.exe+0x523e)
#18 0x00007ff7cd5dc10e (C:\PROGRA~1\LLVM\bin\clang++.exe+0x129c10e)
#19 0x00007ff7cd5dbc1f (C:\PROGRA~1\LLVM\bin\clang++.exe+0x129bc1f)
#20 0x00007ff7cd5da2e2 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x129a2e2)
#21 0x00007ff7cd5d6b8d (C:\PROGRA~1\LLVM\bin\clang++.exe+0x1296b8d)
#22 0x00007ff7cd5d5ed5 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x1295ed5)
#23 0x00007ff7cda3e25b (C:\PROGRA~1\LLVM\bin\clang++.exe+0x16fe25b)
#24 0x00007ff7cda3ba7c (C:\PROGRA~1\LLVM\bin\clang++.exe+0x16fba7c)
#25 0x00007ff7ce346e56 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x2006e56)
#26 0x00007ff7cd7cf5c5 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x148f5c5)
#27 0x00007ff7cc978493 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x638493)
#28 0x00007ff7cc9780cd (C:\PROGRA~1\LLVM\bin\clang++.exe+0x6380cd)
#29 0x00007ff7cc9762c9 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x6362c9)
#30 0x00007ff7cc9721af (C:\PROGRA~1\LLVM\bin\clang++.exe+0x6321af)
#31 0x00007ff7cc970b25 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x630b25)
#32 0x00007ff7cd2c8a5d (C:\PROGRA~1\LLVM\bin\clang++.exe+0xf88a5d)
#33 0x00007ff7ccb401d5 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x8001d5)
#34 0x00007ff7ccb3ffc8 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x7fffc8)
#35 0x00007ff7cc48083b (C:\PROGRA~1\LLVM\bin\clang++.exe+0x14083b)
#36 0x00007ff7cc48017e (C:\PROGRA~1\LLVM\bin\clang++.exe+0x14017e)
#37 0x00007ff7cc47fe92 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x13fe92)
#38 0x00007ff7cc477b0d (C:\PROGRA~1\LLVM\bin\clang++.exe+0x137b0d)
#39 0x00007ff7cc474a83 (C:\PROGRA~1\LLVM\bin\clang++.exe+0x134a83)
#40 0x00007ff7ce39c9ec (C:\PROGRA~1\LLVM\bin\clang++.exe+0x205c9ec)
#41 0x00007ffedc2e259d (C:\Windows\System32\KERNEL32.DLL+0x1259d)
#42 0x00007ffedd56af78 (C:\Windows\SYSTEM32\ntdll.dll+0x5af78)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: C:\Users\Fadya\AppData\Local\Temp\main-468933.cpp
clang++: note: diagnostic msg: C:\Users\Fadya\AppData\Local\Temp\main-468933.sh
clang++: note: diagnostic msg:
********************
ninja: build stopped: subcommand failed.
```
[main-468933.sh](https://github.com/user-attachments/files/26862476/main-468933.sh)
The working pattern (Concept -> Concept, rather than Concept -> Class):
```c++
template
concept FooLike = requires (T& SomeObject) {
SomeObject.Foo();
};
template concept Concept>
concept NotSatisfying = not Concept ;
class NonFooLike {};
int main() {
static_assert (NotSatisfying );
return 0;
}
```
Contributor guide
Research direction
Start by compiling the minimal reproducer in main.cpp with clang++ 22.1.3 and -std=gnu++26, using the attached main-468933.sh or preprocessed source to reproduce the crash. Compare the Concept-to-class case with the working Concept-to-Concept example. Done means the compiler no longer crashes on the reproducer while preserving the working example's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100