[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 15 04:09:03 PDT 2021


mizvekov added a comment.

In D99005#2818606 <https://reviews.llvm.org/D99005#2818606>, @sberg wrote:

> (In a build prior to https://reviews.llvm.org/rGc60dd3b2626a4d9eefd9f82f9a406b0d28d3fd72 "Revert '[clang] NRVO: Improvements and handling of more cases.'") I see the following (reduced from https://git.libreoffice.org/core/+/649313625b94e6b879848fc19b607b74375100bf/o3tl/qa/compile-temporary.cxx) started to fail under `-std=c++2b` with this change (and continues to compile fine with `-std=c++20`):
> It is not clear to me whether that is an intended change in behavior according to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html "Simpler implicit move", or whether it is a bug in this implementation.

Yeah that one is intentional, under P2266 <https://reviews.llvm.org/P2266> as far as implicit move is concerned, that code behaves similarly to this code under C++20 (which is diagnosed for the same reason):

  template <typename T> constexpr T& temporary(T&& x) { return static_cast<T&&>(x); }

If you want this semantics with P2266 <https://reviews.llvm.org/P2266>, you could write:

  template <typename T> constexpr T& temporary(T&& x) { return static_cast<T&>(x); }

And the above also works on C++20.

Thank you for reporting this, it's the kind of feedback we needed about real world usage of code that would break under these new rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005



More information about the cfe-commits mailing list