<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69284>69284</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang hangs when compile attatched bug.cpp
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pbl-pw
</td>
</tr>
</table>
<pre>
# Clang hangs when compile attatched bug.cpp
command line: clang++ -std=c++20 -c bug.cpp -O3
test on msys2 ucrt64 clang and offcial LLVM win64 clang, both hangs.
emit llvm comand line `clang++ -std=c++20 -c bug.cpp -O3 -emit-llvm` ok
run `llc bug.bc` output:
``` cmd
c:/msys2/ucrt64/bin/llc.exe: error: c:/msys2/ucrt64/bin/llc.exe: bug.bc: error: Invalid cast (Producer: 'LLVM17.0.2' Reader: 'LLVM 17.0.2')
```
source bug.cpp:
``` c++
class IFunction
{
void *_ptr;
public:
template <typename T>
constexpr IFunction(T &&obj) noexcept : _ptr{new void *{(void *)&ClassVTable<T>}} {}
public:
struct TRawVTable
{
void (*_operatorCall)(void *);
};
template <typename T> // requires std::is_invocable_r_v<void, T>
static constexpr TRawVTable ClassVTable{[](void *ptr) -> void { return (*(T *)ptr)(); /* return; ok */ }};
};
enum class TrChID : unsigned _BitInt(1) // unsigned _BitInt(2) ok
{
A = 0,
B = 1,
};
extern void other(TrChID chid, IFunction) noexcept;
IFunction func(TrChID chid)
{
return [chid] { other(chid, []() -> void {}); };
}
```
msys2 clang info:
``` cmd
"c:\msys2\ucrt64\bin\clang++.exe" -std=c++20 -c bug.cpp -O3 -v
clang version 17.0.2
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: c:/msys2/ucrt64/bin
(in-process)
"c:/msys2/ucrt64/bin/clang++.exe" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=E:/Projects/bug/.Build -resource-dir c:/msys2/ucrt64/lib/clang/17 -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++ -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/backward -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0 -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0/backward -internal-isystem c:/msys2/ucrt64/include/c++/13.2.0 -internal-isystem c:/msys2/ucrt64/include/c++/13.2.0/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/include/c++/13.2.0/backward -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++ -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/backward -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0/backward -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2/backward -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13/x86_64-w64-mingw32 -internal-isystem c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13/backward -internal-isystem c:/msys2/ucrt64/lib/clang/17/include -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/include -internal-isystem c:/msys2/ucrt64/x86_64-w64-mingw32/usr/include -internal-isystem c:/msys2/ucrt64/include -O3 -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=E:/Projects/bug/.Build -ferror-limit 19 -fmessage-length=220 -femulated-tls -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -exception-model=seh -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o bug.o -x c++ bug.cpp
clang -cc1 version 17.0.2 based upon LLVM 17.0.2 default target x86_64-w64-windows-gnu
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include/c++/13.2.0/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2.0/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13.2/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13/x86_64-w64-mingw32"
ignoring nonexistent directory "c:/msys2/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/g++-v13/backward"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/include"
ignoring nonexistent directory "c:/msys2/ucrt64/x86_64-w64-mingw32/usr/include"
#include "..." search starts here:
#include <...> search starts here:
c:/msys2/ucrt64/include/c++/13.2.0
c:/msys2/ucrt64/include/c++/13.2.0/x86_64-w64-mingw32
c:/msys2/ucrt64/include/c++/13.2.0/backward
c:/msys2/ucrt64/lib/clang/17/include
c:/msys2/ucrt64/include
End of search list.
```
offcial LLVM win64 clang info:
``` cmd
"c:\LLVM\bin\clang++.exe" -std=c++20 -c bug.cpp -O3 -v
clang version 17.0.2
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: c:\LLVM\bin
(in-process)
"c:\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.20.0 -emit-obj -mincremental-linker-compatible -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug.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 -v "-fcoverage-compilation-dir=E:\\Projects\\bug\\.Build" -resource-dir "c:\\LLVM\\lib\\clang\\17" -internal-isystem "c:\\LLVM\\lib\\clang\\17\\include" -internal-isystem "C:/Program Files/Microsoft Visual Studio 10.0/VC/include" -internal-isystem "C:/Program Files/Microsoft Visual Studio 9.0/VC/include" -internal-isystem "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include" -internal-isystem "C:/Program Files/Microsoft Visual Studio 8/VC/include" -internal-isystem "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include" -O3 -std=c++20 -fdeprecated-macro "-fdebug-compilation-dir=E:\\Projects\\bug\\.Build" -ferror-limit 19 -fmessage-length=220 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.20 -fdelayed-template-parsing -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o bug.o -x c++ bug.cpp
clang -cc1 version 17.0.2 based upon LLVM 17.0.2 default target x86_64-pc-windows-msvc
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 10.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
#include "..." search starts here:
#include <...> search starts here:
c:\LLVM\lib\clang\17\include
End of search list.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl9v2zgS_zTMy4CGTfnvQx4SuwaK28UVu0FfA4oayWwpUkdSjnOf_kBKlp3ETtMkdnJYoI1tcjR_fkMOZ4bizslCI16S0TUZLS547VfGXlapotXdRWqy-0vCEpgrrgtYcV04uFuhBmHKSioE7j33YoUZpHXRE1VF-gvSv2r-ClOWXGegpEaSXIEIXAi7JuwaqPMZSRai-cn6QMWWBdB_Jw0Dj86D0VC6e8egFtaPhw0XCHxNngvJFfzxx_c_4U7q7SRhc0iNXzUK9_ZVwlJ6UGpdBgu2ugEZ939DN6CBCw1cyLgP5ue-AFvrwE6p5pFURJLaV7UnydU-JRn3m38gyqwFLJCwZTSXsGVjMGHLVGrClkqJHm4ikmitsRHSlz7RKrP_7Fe95kpmILjzQNj0mzVZLTDOETYJqA4mvX6PETaBv5BnD6agmyNs9siifTOdqa3AbnkcxaABu8VBcefg67LWwkujW9pJOwtrIzMg7Oq28pYk1_sMqzpVUnRSwGNZKe4RSDL39xVqXiLckORLOy-Mdh43ld2TxqY3QNiYsLFJfxA2A21wI7DyEMyPQifXGu86PYJmbNr9YjPCxvNgwvcbniokyTxKnCzIZAGBeLJ4TmfnbS083PzF71oGzfgOgK3kaQDBVGi5N3bOlYqyH2iyhQeC0IdYHQcHCFsStgSL_6mlRQdxQ1yR5Eq6W6nXRgS1bu3tmiTzIC3suD1Unedeij1wd7bAPjCT6ybs7Okc0GUzoEGLZmxyDRZ9bXVrcOufYF1DHIeDpY3aVy15GDA_G8olNOjvEHiCBuq6hGbh3dj56usiervWMT5mcHst_VftCZsOgn4tQAemWZjuYkLnsisgyQL6hM3bges4MOgGDmi08Wh1g4LxK7TB8kY1sWow31u0u2X6iE1HA3mtxWMes8eKbrEeXUeCUVyxnfyt4M5vT5wV7Gi98Qjv4zGiie9NYJc6N7-OlISxuGNG8yb0jeZt6BvNQ-gbzffieQyBjD0N60_i-roLP7qANVoXUGvjXJy54bb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