[libcxx-commits] [libcxx] [libc++] Resolve LWG4366: Heterogeneous comparison of `expected` may be ill-formed (PR #185342)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 15 20:38:30 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libcxx/include/__expected/expected.h libcxx/test/std/utilities/expected/expected.expected/equality/equality.T2.pass.cpp libcxx/test/std/utilities/expected/expected.expected/equality/equality.unexpected.pass.cpp libcxx/test/support/test_comparisons.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h
index c4b1a37c7..80132f442 100644
--- a/libcxx/include/__expected/expected.h
+++ b/libcxx/include/__expected/expected.h
@@ -449,9 +449,7 @@ private:
 // Helper to handle cases for LWG4366 Heterogeneous comparison of ``expected`` may be ill-formed
 // Where the comparison may produce a value that is a type that is not bool, and is implicitly
 // convertible to bool, but not explicitly.
-constexpr bool __into_bool(bool __b) noexcept {
-  return __b;
-}
+constexpr bool __into_bool(bool __b) noexcept { return __b; }
 
 template <class _Tp, class _Err>
 class expected : private __expected_base<_Tp, _Err> {

``````````

</details>


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


More information about the libcxx-commits mailing list