[libcxx-commits] [PATCH] D147741: [libc++, std::vector] call the optimized version of __uninitialized_allocator_copy for trivial types

Hans Wennborg via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 9 01:51:40 PDT 2023


hans added a comment.

We're hitting build failures after this change. Here's a reduced version:

  $ cat /tmp/a.cc
  #include <vector>
  
  void f(volatile int *p, int n) {
    std::vector<int> v(p, p + n);
  }
  
  $ build2/bin/clang -c -std=c++20 -stdlib=libc++ /tmp/a.cc
  In file included from /tmp/a.cc:1:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/vector:317:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/__format/formatter_bool.h:17:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/__format/concepts.h:17:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/__format/format_parse_context.h:16:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/string_view:1048:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/algorithm:1946:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/memory:896:
  In file included from /work/llvm-project/build2/bin/../include/c++/v1/__memory/ranges_uninitialized_algorithms.h:22:
  /work/llvm-project/build2/bin/../include/c++/v1/__memory/uninitialized_algorithms.h:589:12: error: cannot initialize return object of type 'int *' with an rvalue of type 'volatile int *'
      return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /work/llvm-project/build2/bin/../include/c++/v1/__memory/uninitialized_algorithms.h:596:26: note: in instantiation of function template specialization 'std::__uninitialized_allocator_copy_impl<std::allocator<int>, volatile int, volatile int, int, nullptr>' requested here
      auto __result = std::__uninitialized_allocator_copy_impl(__alloc, __unwrapped_range.first, __unwrapped_range.second, std::__unwrap_iter(__first2));
                           ^
  /work/llvm-project/build2/bin/../include/c++/v1/vector:1161:22: note: in instantiation of function template specialization 'std::__uninitialized_allocator_copy<std::allocator<int>, volatile int *, volatile int *, int *>' requested here
    __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);
                       ^
  /work/llvm-project/build2/bin/../include/c++/v1/vector:790:9: note: in instantiation of function template specialization 'std::vector<int>::__construct_at_end<volatile int *, volatile int *>' requested here
          __construct_at_end(__first, __last, __n);
          ^
  /work/llvm-project/build2/bin/../include/c++/v1/vector:1278:3: note: in instantiation of function template specialization 'std::vector<int>::__init_with_size<volatile int *, volatile int *>' requested here
    __init_with_size(__first, __last, __n);
    ^
  /tmp/a.cc:4:20: note: in instantiation of function template specialization 'std::vector<int>::vector<volatile int *, 0>' requested here
    std::vector<int> v(p, p + n);
                     ^
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147741



More information about the libcxx-commits mailing list