Skip to content

Clang-tidy run by MSVC crashes when trying to transform vectorΒ #108932

@kimbirkelund

Description

@kimbirkelund

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidycrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions