[libcxx-commits] [PATCH] D130695: [libc++][ranges]Refactor `copy{, _backward}` and `move{, _backward}`

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Oct 2 08:34:21 PDT 2022


mstorsjo added a comment.

In D130695#3829567 <https://reviews.llvm.org/D130695#3829567>, @mstorsjo wrote:

> I suspect issues in this commit. If Clang is built on top of libc++ with this change in, Clang misbehaves (produces incorrect behaviour and then crashes) - I have bisected the issue down to this exact commit.
>
> I don't know exactly what/why etc yet.

I don't think I'll be able to spend time on figuring out exactly what this patch breaks, but to reproduce the issue:

1. Build libc++
2. Build clang using the libc++ from 1. as standard C++ library
3. Use clang from 2. to build a trivial C++ application

The test application I've tried to build in step 3 is https://github.com/mstorsjo/llvm-mingw/blob/master/test/hello-cpp.cpp, with a trivial compilation command like `i686-w64-mingw32-clang++ hello-cpp.cpp -o i686/hello-cpp.exe`. When building this trivial C++ example, Clang incorrectly produces these diagnostics:

  In file included from hello-cpp.cpp:19:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/iostream:43:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/ios:221:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/__locale:15:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/__memory/shared_ptr.h:22:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/__memory/allocation_guard.h:14:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/__memory/allocator_traits.h:14:
  In file included from D:/a/_temp/msys64/llvm-mingw/include/c++/v1/__memory/construct_at.h:20:
  D:/a/_temp/msys64/llvm-mingw/include/c++/v1/new:285:12: error: no matching function for call to '__libcpp_operator_new'
      return __libcpp_operator_new(__size, __align_val);
             ^~~~~~~~~~~~~~~~~~~~~
  D:/a/_temp/msys64/llvm-mingw/include/c++/v1/new:262:7: note: candidate template ignored: substitution failure: deduced incomplete pack <size_t, (no value)> for template parameter '_Args'
  void* __libcpp_operator_new(_Args ...__args) {
        ^
  D:/a/_temp/msys64/llvm-mingw/include/c++/v1/new:326:14: error: no matching function for call to '__libcpp_operator_delete'
        return __libcpp_operator_delete(__ptr, __align_val);
               ^~~~~~~~~~~~~~~~~~~~~~~~
  D:/a/_temp/msys64/llvm-mingw/include/c++/v1/new:272:6: note: candidate template ignored: substitution failure: deduced incomplete pack <void *, (no value)> for template parameter '_Args'
  void __libcpp_operator_delete(_Args ...__args) {
       ^

And after that, Clang crashes. See https://github.com/mstorsjo/llvm-mingw/actions/runs/3166862572/jobs/5158428014 for the issue in action.

Note that while this could look like an issue in the libc++ headers that Clang is including here, the same issue does not appear when Clang is built on top of a preexisting libstdc++ or older libc++.

I haven't tested, but would presume that the same issue appears when Clang targets other OSes too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130695/new/

https://reviews.llvm.org/D130695



More information about the libcxx-commits mailing list