<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108932>108932</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-tidy run by MSVC crashes when trying to transform vector
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kimbirkelund
</td>
</tr>
</table>
<pre>
The following program fails:
```
#include <gtest/gtest.h>
#include <vector>
#include <ranges>
TEST(Transform, ShouldWork) {
std::vector input = {1,2,3,4,5};
auto transformed = input | std::ranges::views::transform([](auto i) { return i; });
std::vector output(transformed.begin(), transformed.end());
}
```
With this output:
```
>------ Build started: Project: CMakeLists, Configuration: Debug ------
[1/7] Scanning x:\tests\TransformTests.cpp for CXX dependencies
[2/7] Generating CXX dyndep file tests\CMakeFiles\Foo.dir\CXX.dd
[3/4] Building CXX object tests\CMakeFiles\Foo.dir\TransformTests.cpp.obj
FAILED: tests/CMakeFiles/Foo.dir/TransformTests.cpp.obj
C:\cmake\3.30.2\bin\cmake.exe -E __run_co_compile --tidy=clang-tidy;-checks=cppcoreguidelines-*,-cppcoreguidelines-owning-memory,-cppcoreguidelines-avoid-magic-numbers,-clang-diagnostic-c++20-extensions;--extra-arg=/EHsc;--extra-arg-before=--driver-mode=cl --source=x:\tests\TransformTests.cpp -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe /nologo /TP -DCMS_NO_REGISTER_KEYWORD -DGLEW_STATIC -DLIBXML_STATIC -DNOGDI -DNOMINMAX -DPROJ_DLL="" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_FOREACH -DQT_OPENGLWIDGETS_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DTINYXML2_DEBUG -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_FILE_OFFSET_BITS=64 -D_UNICODE -D_USE_MATH_DEFINES -D_WIN64 -external:W0 /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++20 -MDd -Zi /W4 /MP /external:templates- /bigobj /Zi /EHsc -Zc:__cplusplus -permissive- -utf-8 /showIncludes @tests\CMakeFiles\Foo.dir\TransformTests.cpp.obj.modmap /Fotests\CMakeFiles\Foo.dir\TransformTests.cpp.obj /Fdtests\CMakeFiles\Foo.dir\ /FS -c x:\tests\TransformTests.cpp
Error running 'clang-tidy': PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
1. <eof> parser at end of file
2. While analyzing stack:
#0 Calling std::ranges::_Range_closure<std::ranges::views::_Transform_fn, (lambda at x:\tests\TransformTests.cpp:9:62)>::_Call(class std::ranges::_Range_closure<struct std::ranges::views::_Transform_fn, class (lambda at x:\tests\TransformTests.cpp:9:62)> &&, class std::vector<int> &, index_sequence<0ULL>) at line C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\ranges:947:20
#1 Calling std::ranges::_Range_closure<std::ranges::views::_Transform_fn, (lambda at x:\tests\TransformTests.cpp:9:62)>::operator()(class std::vector<int> &) at line C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\ranges:200:20 <Spelling=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\yvals_core.h:1894:17>
#2 Calling std::ranges::_Pipe::operator|(class std::vector<int> &, class std::ranges::_Range_closure<struct std::ranges::views::_Transform_fn, class (lambda at x:\tests\TransformTests.cpp:9:62)> &&) at line 9
#3 Calling Transform_ShouldWork_Test::TestBody()
3. C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\ranges:962:51 <Spelling=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\yvals_core.h:1894:17>: Error evaluating statement
4. C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\ranges:962:51 <Spelling=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\yvals_core.h:1894:17>: Error evaluating statement
Exception Code: 0xC0000005
#0 0x00007ff64a790b2e (C:\llvm\current\bin\clang-tidy.exe+0x17d0b2e)
#1 0x00007ff64a3eeac4 (C:\llvm\current\bin\clang-tidy.exe+0x142eac4)
#2 0x00007ff64a3eae22 (C:\llvm\current\bin\clang-tidy.exe+0x142ae22)
#3 0x00007ff64a45a07a (C:\llvm\current\bin\clang-tidy.exe+0x149a07a)
#4 0x00007ff64a7e0294 (C:\llvm\current\bin\clang-tidy.exe+0x1820294)
#5 0x00007ff64a7e4eac (C:\llvm\current\bin\clang-tidy.exe+0x1824eac)
#6 0x00007ff64a7e7661 (C:\llvm\current\bin\clang-tidy.exe+0x1827661)
#7 0x00007ff64a445e4b (C:\llvm\current\bin\clang-tidy.exe+0x1485e4b)
#8 0x00007ff64a443981 (C:\llvm\current\bin\clang-tidy.exe+0x1483981)
#9 0x00007ff64a4437cb (C:\llvm\current\bin\clang-tidy.exe+0x14837cb)
#10 0x00007ff64a4570c0 (C:\llvm\current\bin\clang-tidy.exe+0x14970c0)
#11 0x00007ff64a45634c (C:\llvm\current\bin\clang-tidy.exe+0x149634c)
#12 0x00007ff64a221b61 (C:\llvm\current\bin\clang-tidy.exe+0x1261b61)
#13 0x00007ff64a2160ba (C:\llvm\current\bin\clang-tidy.exe+0x12560ba)
#14 0x00007ff64a229263 (C:\llvm\current\bin\clang-tidy.exe+0x1269263)
#15 0x00007ff649ccb208 (C:\llvm\current\bin\clang-tidy.exe+0xd0b208)
#16 0x00007ff648fdd981 (C:\llvm\current\bin\clang-tidy.exe+0x1d981)
#17 0x00007ff648fdd3f2 (C:\llvm\current\bin\clang-tidy.exe+0x1d3f2)
#18 0x00007ff6494c1ae7 (C:\llvm\current\bin\clang-tidy.exe+0x501ae7)
#19 0x00007ff64933e245 (C:\llvm\current\bin\clang-tidy.exe+0x37e245)
#20 0x00007ff6494c1985 (C:\llvm\current\bin\clang-tidy.exe+0x501985)
#21 0x00007ff6494c07cb (C:\llvm\current\bin\clang-tidy.exe+0x5007cb)
#22 0x00007ff6494c307c (C:\llvm\current\bin\clang-tidy.exe+0x50307c)
#23 0x00007ff64933a0a9 (C:\llvm\current\bin\clang-tidy.exe+0x37a0a9)
#24 0x00007ff649304b01 (C:\llvm\current\bin\clang-tidy.exe+0x344b01)
#25 0x00007ff64a1594b0 (C:\llvm\current\bin\clang-tidy.exe+0x11994b0)
#26 0x00007ffc59ce257d (C:\Windows\System32\KERNEL32.DLL+0x1257d)
#27 0x00007ffc5adaaf28 (C:\Windows\SYSTEM32\ntdll.dll+0x5af28)
Access violation
ninja: build stopped: subcommand failed.
```
This executes within my existing cmake setup. If a fully standalone repro is required, please let me known.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsmd9zozjywP8a5UWFCwTY5iEPNuCMv-sf-caeTXZfKAHC1gYQK4n8uIf9268abMcwc5st7upuruqmMmCB-qOm1epuAVWKH0rGbpE7R25wQ2t9FPL2mRcxl88sr8v0Jhbp--3-yHAm8ly88vKAKykOkhY4ozxXyJ4hM0Dm-Tg2T39tk9i8TPI6ZRjZ_kEzpRFZNOfREdlhR7TT94UlWsiPLp2bkpYHpnry-3C3R2S6l7RUmZAFIj7eHUWdp49CPiPiYTSZt10xxljpFHS3Z-1ImJdVrTGyA-hmIeITRHwbEd9BxHfRJED2_Ho4YNBaC6zPA7K0ET-BJv7HEGd9m-E4ez391B-qTtspQGTaMPlJXSyZrmWJObLnGHQgXl-N_nOIWle1RmR6pdcoZgdewijEA7Nc32Jler7RZ8OA353V5vjI9RHrI1fnIf_cE-zQaP7hec3zFCtNpWagOr6X4jeWgDz21_SZrbjSCtT0RZnxQy2p5qKE2wGL6wNuOedZQC7M1mKC3ADvElqW4KJvoIzrg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