Libtorch project with clang-tidy produces errors

tuero: <p>I’m having an odd error with <code>clang-tidy</code>, when changing the C++ standard from 17 to 20. Here is a simple reproducible example:</p>
<p><code>main.cpp</code></p>
<pre><code class="lang-c++">#include &lt;torch/torch.h&gt;
int main() {
    return 0;
}
</code></pre>
<p><code>CMakeLists.txt</code></p>
<pre><code class="lang-auto">cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

add_executable(main main.cpp)
target_link_libraries(main "${TORCH_LIBRARIES}")
set_property(TARGET main PROPERTY CXX_STANDARD 17)
target_compile_options(main PUBLIC
    -Wall -Wextra
)
</code></pre>
<p>Running cmake to produce the compile commands:</p>
<pre data-code-wrap="shell"><code class="lang-plaintext">mkdir build &amp;&amp; cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_PREFIX_PATH=/usr/local/libtorch ..
cp compile_commands.json ..  &amp;&amp; cd ..
</code></pre>
<p>Finally, running <code>clang-tidy -p . main.cpp</code> produces no warning/errors.</p>
<p>If however <code>CXX_STANDARD 20</code> is used instead, the following error is produced by clang-tidy.</p>
<pre><code class="lang-auto">clang-tidy -p . main.cpp
Error while processing /home/tuero/Documents/test/test_torch/main.cpp.
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:188:7: error: static assertion failed due to requirement 'is_destructible&lt;c10::IValue&gt;::value': value type is destructible [clang-diagnostic-error]
      static_assert(is_destructible&lt;_Value_type&gt;::value,
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:850:7: note: in instantiation of function template specialization 'std::_Destroy&lt;__gnu_cxx::__normal_iterator&lt;c10::IValue *, std::vector&lt;c10::IValue&gt;&gt;&gt;' requested here
      _Destroy(__first, __last);
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/vector.tcc:244:13: note: in instantiation of function template specialization 'std::_Destroy&lt;__gnu_cxx::__normal_iterator&lt;c10::IValue *, std::vector&lt;c10::IValue&gt;&gt;, c10::IValue&gt;' requested here
              std::_Destroy(std::copy(__x.begin(), __x.end(), begin()),
                   ^
/usr/local/libtorch/include/ATen/core/ivalue_inl.h:432:25: note: in instantiation of member function 'std::vector&lt;c10::IValue&gt;::operator=' requested here
        elementsVector_ = rhs.elementsVector_;
                        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_uninitialized.h:125:4: error: no matching function for call to '_Destroy' [clang-diagnostic-error]
          std::_Destroy(__result, __cur);
          ^~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_uninitialized.h:370:14: note: in instantiation of function template specialization 'std::__do_uninit_copy&lt;const c10::IValue *, c10::IValue *&gt;' requested here
        return std::__do_uninit_copy(__first, __last, __result);
                    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:1690:11: note: in instantiation of function template specialization 'std::__uninitialized_copy_a&lt;const c10::IValue *, c10::IValue *, c10::IValue&gt;' requested here
            std::__uninitialized_copy_a(__first, __last,
                 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:706:4: note: in instantiation of function template specialization 'std::vector&lt;c10::IValue&gt;::_M_range_initialize&lt;const c10::IValue *&gt;' requested here
          _M_range_initialize(__first, __last,
          ^
/usr/local/libtorch/include/ATen/core/ivalue_inl.h:353:32: note: in instantiation of function template specialization 'std::vector&lt;c10::IValue&gt;::vector&lt;const c10::IValue *, void&gt;' requested here
        new (&amp;elementsVector_) std::vector&lt;IValue&gt;(elements.begin(), elements.end());
                               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:182:5: note: candidate template ignored: substitution failure [with _ForwardIterator = c10::IValue *]
    _Destroy(_ForwardIterator __first, _ForwardIterator __last)
    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:146:5: note: candidate function template not viable: requires single argument '__pointer', but 2 arguments were provided
    _Destroy(_Tp* __pointer)
    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:832:5: note: candidate function template not viable: requires 3 arguments, but 2 were provided
    _Destroy(_ForwardIterator __first, _ForwardIterator __last,
    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:847:5: note: candidate function template not viable: requires 3 arguments, but 2 were provided
    _Destroy(_ForwardIterator __first, _ForwardIterator __last,
</code></pre>
<p>Here are my versions:</p>
<pre><code class="lang-auto">$ g++ --version
g++ (Ubuntu 11.3.0-6ubuntu1) 11.3.0
$ clang-14 --version
Ubuntu clang version 14.0.6-2
$ clang-15 --version
Ubuntu clang version 15.0.7
$ cat /usr/local/libtorch/build-version
2.0.1+cu118
</code></pre>