[libcxx-commits] [libcxx] [libc++] Fix `expected::error_or(...) &&` test (PR #215553)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 11 06:21:02 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: David Bayer (davebayer)

<details>
<summary>Changes</summary>

In tests that should test the `expected::error_or(...) &&` member function the `e` member is declared as `const`, thus the `const &` version is used and the `&&` overload stays untested. This PR removes the `const` specifier from the variable.

---
Full diff: https://github.com/llvm/llvm-project/pull/215553.diff


2 Files Affected:

- (modified) libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp (+2-2) 
- (modified) libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp (+2-2) 


``````````diff
diff --git a/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
index f698f44ba8f3a..3052bc2974066 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
@@ -39,14 +39,14 @@ constexpr bool test_default_template_arg() {
 
   // &&, has_value()
   {
-    const std::expected<int, ConstructFromInt> e(5);
+    std::expected<int, ConstructFromInt> e(5);
     std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
     assert(x.value == 10);
   }
 
   // &&, !has_value()
   {
-    const std::expected<int, ConstructFromInt> e(std::unexpect, 5);
+    std::expected<int, ConstructFromInt> e(std::unexpect, 5);
     std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
     assert(x.value == 5);
   }
diff --git a/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp b/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
index db2891f61c3cb..e5d9b1dc2eeaf 100644
--- a/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
@@ -39,14 +39,14 @@ constexpr bool test_default_template_arg() {
 
   // &&, has_value()
   {
-    const std::expected<void, ConstructFromInt> e;
+    std::expected<void, ConstructFromInt> e;
     std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
     assert(x.value == 10);
   }
 
   // &&, !has_value()
   {
-    const std::expected<void, ConstructFromInt> e(std::unexpect, 5);
+    std::expected<void, ConstructFromInt> e(std::unexpect, 5);
     std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
     assert(x.value == 5);
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/215553


More information about the libcxx-commits mailing list