[all-commits] [llvm/llvm-project] 915f2f: [libc++][test] Avoid MSVC constexpr bug

Casey Carter via All-commits all-commits at lists.llvm.org
Mon Jan 9 17:48:23 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 915f2f16fbb75793bfaface6efdce7ef31d2da52
      https://github.com/llvm/llvm-project/commit/915f2f16fbb75793bfaface6efdce7ef31d2da52
  Author: Casey Carter <Casey at Carter.net>
  Date:   2023-01-09 (Mon, 09 Jan 2023)

  Changed paths:
    M libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp

  Log Message:
  -----------
  [libc++][test] Avoid MSVC constexpr bug

C++ constexpr allows a non-constant-expresssion lvalue to be used in a constant expression if it's not subject to lvalue-to-rvalue conversion. Subtly, this means you can make a constant-expression copy of a non-constant-expression object of empty type since the copy constructor doesn't perform lvalue-to-rvalue conversion. MSVC has had bugs with this usage forever, which will hopefully finally be mashed implementing C++23's relaxation on the use of pointers and references in constant expressions.

There's no need for this particular test to use this particular constexpr feature, we can simply make the predicates constant expressions.

Differential Revision: https://reviews.llvm.org/D141336




More information about the All-commits mailing list