[all-commits] [llvm/llvm-project] b5fa9e: [libc++] Implement LWG3918: copy elision in `std::...

inquisitivecrystal via All-commits all-commits at lists.llvm.org
Wed Jul 8 05:07:21 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b5fa9eee6798b678fc7cb5f2b42a977932b708f9
      https://github.com/llvm/llvm-project/commit/b5fa9eee6798b678fc7cb5f2b42a977932b708f9
  Author: inquisitivecrystal <thoughtsoflifeandlight17 at gmail.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M libcxx/docs/Status/Cxx26Issues.csv
    M libcxx/include/__memory/uninitialized_algorithms.h
    M libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp
    M libcxx/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp

  Log Message:
  -----------
  [libc++] Implement LWG3918: copy elision in `std::uninitialized_move/_n` (#207692)

This implements [LWG3918](https://wg21.link/LWG3918), which guarantees
copy elision for rvalues in `std::uninitialized_move/_n`. It also
implements [LWG4452](https://wg21.link/LWG4452), a minor correction that
makes the helper added by LWG3918 constexpr.

This additionally fixes a bug in `std::uninitialized_move/_n` where they
could create and then access dangling references. The previous
implementation used the following lambda as an implementation detail:
```c++
[](auto&& __iter) -> decltype(auto) { return std::move(*__iter); }
```
When `__iter` is a prvalue, this creates a temporary object within the
lambda's body and `std::move` then returns a reference to that object.
The reference dangles as soon as control leaves the lambda. This
behavior was not permitted by the standard even before LWG3918.

The new implementation fixes the bug by using a helper,
`std::__deref_move(__iter)`, which returns `*__iter` directly when
`*__iter` is already an rvalue.

Resolves #118339.
Resolves #171416.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list