[libcxx-commits] [PATCH] D91981: [libc++] Remove _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 23 10:23:07 PST 2020


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, zoecarver.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Quuxplusone requested review of this revision.

Zoe Carver says: "We decided that libc++ only supports C++20 constexpr algorithms when `is_constant_evaluated` is also supported. Here's a link to the discussion."
https://reviews.llvm.org/D65721#inline-735682

After this patch, the following C++20 test case seems to work okay for me in all its configurations:

  // clang++ -std=c++20 -DX=0 should work
  // clang++ -std=c++20 -DX=1 should work
  // clang++ -std=c++20 -DX=2 should work
  // clang++ -std=c++20 -DX=3 should not work
  
  #if X & 1
  #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
  #endif
  
  #include <algorithm>
  
  constexpr int test() {
      int x[10] {};
      int y[10] {};
      std::copy(x, x+10, y);
      std::copy_n(x, 10, y);
      std::move(x, x+10, y);
      std::copy_backward(x, x+10, y+10);
      std::move_backward(x, x+10, y+10);
      return 0;
  }
  
  int main() {
  #if X & 2
      constexpr int i = test();
  #else
      const int i = test();
  #endif
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91981

Files:
  libcxx/include/__config
  libcxx/include/__string
  libcxx/include/algorithm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91981.307116.patch
Type: text/x-patch
Size: 7360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201123/71258f73/attachment.bin>


More information about the libcxx-commits mailing list