| Issue |
60615
|
| Summary |
Clang frontend segmentation fault when using a scoped static variable as a template argument inside a template
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Sauroniux
|
Command: `clang++ -std=c++17 Test.cpp`
Source file:
```
template <unsigned Strs>
static auto join_v = 0;
template<typename T>
void foo()
{
static constexpr unsigned scoped_static = 123;
auto bar = join_v<scoped_static>;
}
int main()
{
foo<int>();
return 0;
}
```
Output:
```
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: D:\\Programming\\LLVM\\bin\\clang++.exe -cc1 -triple x86_64-pc-windows-msvc19.34.31937 -emit-obj -mrelax-all -mincremental-linker-compatible --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -fcoverage-compilation-dir=D:\\Programming\\Medusa\\clang_crash -resource-dir D:\\Programming\\LLVM\\lib\\clang\\15.0.6 -internal-isystem D:\\Programming\\LLVM\\lib\\clang\\15.0.6\\include -internal-isystem G:\\VisualStudio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\include -internal-isystem G:\\VisualStudio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\atlmfc\\include -internal-isystem "D:\\Windows Kits\\10\\Include\\10.0.22000.0\\ucrt" -internal-isystem "D:\\Windows Kits\\10\\Include\\10.0.22000.0\\shared" -internal-isystem "D:\\Windows Kits\\10\\Include\\10.0.22000.0\\um" -internal-isystem "D:\\Windows Kits\\10\\Include\\10.0.22000.0\\winrt" -internal-isystem "D:\\Windows Kits\\10\\Include\\10.0.22000.0\\cppwinrt" -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=D:\\Programming\\Medusa\\clang_crash -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.34.31937 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o C:\\Users\\AUGUST~1\\AppData\\Local\\Temp\\Test-14f1b4.o -x c++ Test.cpp
1. Test.cpp:8:34: current parser token ';'
2. Test.cpp:6:1: parsing function body 'foo'
3. Test.cpp:6:1: in compound statement ('{}')
Exception Code: 0xC0000005
#0 0x00007ff70dda46da (D:\Programming\LLVM\bin\clang++.exe+0x39446da)
#1 0x00007ff70ddeddb5 (D:\Programming\LLVM\bin\clang++.exe+0x398ddb5)
#2 0x00007ff70bdbc31d (D:\Programming\LLVM\bin\clang++.exe+0x195c31d)
#3 0x00007ff70dda84dd (D:\Programming\LLVM\bin\clang++.exe+0x39484dd)
#4 0x00007ff70ddab9a4 (D:\Programming\LLVM\bin\clang++.exe+0x394b9a4)
#5 0x00007ff70d4dcb33 (D:\Programming\LLVM\bin\clang++.exe+0x307cb33)
#6 0x00007ff70ddade5f (D:\Programming\LLVM\bin\clang++.exe+0x394de5f)
#7 0x00007ff70ddac49e (D:\Programming\LLVM\bin\clang++.exe+0x394c49e)
#8 0x00007ff70ddab9f8 (D:\Programming\LLVM\bin\clang++.exe+0x394b9f8)
#9 0x00007ff70d0cf8e8 (D:\Programming\LLVM\bin\clang++.exe+0x2c6f8e8)
#10 0x00007ff70d0cfd1b (D:\Programming\LLVM\bin\clang++.exe+0x2c6fd1b)
#11 0x00007ff70d0d03e2 (D:\Programming\LLVM\bin\clang++.exe+0x2c703e2)
#12 0x00007ff70e2f7c39 (D:\Programming\LLVM\bin\clang++.exe+0x3e97c39)
#13 0x00007ff70e2f44fe (D:\Programming\LLVM\bin\clang++.exe+0x3e944fe)
#14 0x00007ff70e2ee4de (D:\Programming\LLVM\bin\clang++.exe+0x3e8e4de)
#15 0x00007ff70e2edf45 (D:\Programming\LLVM\bin\clang++.exe+0x3e8df45)
#16 0x00007ff70e33aa3f (D:\Programming\LLVM\bin\clang++.exe+0x3edaa3f)
#17 0x00007ff70e338d96 (D:\Programming\LLVM\bin\clang++.exe+0x3ed8d96)
#18 0x00007ff70e34283e (D:\Programming\LLVM\bin\clang++.exe+0x3ee283e)
#19 0x00007ff70e343b86 (D:\Programming\LLVM\bin\clang++.exe+0x3ee3b86)
#20 0x00007ff70e2e14f4 (D:\Programming\LLVM\bin\clang++.exe+0x3e814f4)
#21 0x00007ff70d2852b5 (D:\Programming\LLVM\bin\clang++.exe+0x2e252b5)
#22 0x00007ff70d287d69 (D:\Programming\LLVM\bin\clang++.exe+0x2e27d69)
#23 0x00007ff70bdbe69b (D:\Programming\LLVM\bin\clang++.exe+0x195e69b)
#24 0x00007ff70bdbf0b6 (D:\Programming\LLVM\bin\clang++.exe+0x195f0b6)
#25 0x00007ff70df800a7 (D:\Programming\LLVM\bin\clang++.exe+0x3b200a7)
#26 0x00007ff70d59dffe (D:\Programming\LLVM\bin\clang++.exe+0x313dffe)
#27 0x00007ff70bea6cc2 (D:\Programming\LLVM\bin\clang++.exe+0x1a46cc2)
#28 0x00007ff70ac3580d (D:\Programming\LLVM\bin\clang++.exe+0x7d580d)
#29 0x00007ff70acc6e9e (D:\Programming\LLVM\bin\clang++.exe+0x866e9e)
#30 0x00007ff70a467b1b (D:\Programming\LLVM\bin\clang++.exe+0x7b1b)
#31 0x00007ff70a464a73 (D:\Programming\LLVM\bin\clang++.exe+0x4a73)
#32 0x00007ff70a46480f (D:\Programming\LLVM\bin\clang++.exe+0x480f)
#33 0x00007ff70e64a730 (D:\Programming\LLVM\bin\clang++.exe+0x41ea730)
#34 0x00007ffb80887614 (C:\Windows\System32\KERNEL32.DLL+0x17614)
#35 0x00007ffb826a26a1 (C:\Windows\SYSTEM32\ntdll.dll+0x526a1)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 15.0.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\Programming\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\AUGUST~1\AppData\Local\Temp\Test-704475.cpp
clang++: note: diagnostic msg: C:\Users\AUGUST~1\AppData\Local\Temp\Test-704475.sh
clang++: note: diagnostic msg:
********************
```
The crash occurs if a static variable that is scoped to a template function is used as a template argument for a const reference.
To the report I attach a zip with the `Test.cpp` input file and the 2 output files of the crash. I didn't run `creduce` since this is already only 15 lines with no includes.
[clang_crash.zip](https://github.com/llvm/llvm-project/files/10691534/clang_crash.zip)
Let me know if I can be of further help.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs