[libcxx-commits] [libcxx] [libc++][test] Suppress warning on bitwise shift with `bool` operands in `std::byte` tests for MSVC (PR #212433)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 28 01:46:24 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: A. Jiang (frederick-vs-ja)
<details>
<summary>Changes</summary>
It was intentional in https://llvm.org/PR204116 that tests for `operator<<`, `operator<<=`, `operator>>`, `operator>>=` used `bool` operands, because `bool` is an integral type and thus satisfies the constraints of these operators.
However, MSVC considers `bool` is unsafe as an operand of bitwise shift operators and emits warning C4804. So this patch suppresses the warning for MSVC.
---
Full diff: https://github.com/llvm/llvm-project/pull/212433.diff
4 Files Affected:
- (modified) libcxx/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp (+3)
- (modified) libcxx/test/std/language.support/support.types/byteops/lshift.pass.cpp (+3)
- (modified) libcxx/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp (+3)
- (modified) libcxx/test/std/language.support/support.types/byteops/rshift.pass.cpp (+3)
``````````diff
diff --git a/libcxx/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp b/libcxx/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
index 2c63be98ad86a..8b1569ab3036e 100644
--- a/libcxx/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
@@ -12,6 +12,9 @@
// constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
// Constraints: is_integral_v<IntType> is true.
+// MSVC warning C4804: '<<': unsafe use of type 'bool' in operation
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4804
+
#include <cassert>
#include <cstddef>
#include <type_traits>
diff --git a/libcxx/test/std/language.support/support.types/byteops/lshift.pass.cpp b/libcxx/test/std/language.support/support.types/byteops/lshift.pass.cpp
index 86041def46095..2585162880066 100644
--- a/libcxx/test/std/language.support/support.types/byteops/lshift.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/byteops/lshift.pass.cpp
@@ -12,6 +12,9 @@
// constexpr byte operator<<(byte b, IntType shift) noexcept;
// Constraints: is_integral_v<IntType> is true.
+// MSVC warning C4804: '<<': unsafe use of type 'bool' in operation
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4804
+
#include <cassert>
#include <cstddef>
#include <type_traits>
diff --git a/libcxx/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp b/libcxx/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
index 2fd558c1bf544..bbac97bfc1d46 100644
--- a/libcxx/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
@@ -12,6 +12,9 @@
// constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
// Constraints: is_integral_v<IntType> is true.
+// MSVC warning C4804: '>>': unsafe use of type 'bool' in operation
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4804
+
#include <cassert>
#include <cstddef>
#include <type_traits>
diff --git a/libcxx/test/std/language.support/support.types/byteops/rshift.pass.cpp b/libcxx/test/std/language.support/support.types/byteops/rshift.pass.cpp
index ded075febfc55..b1b91b4e0fe6d 100644
--- a/libcxx/test/std/language.support/support.types/byteops/rshift.pass.cpp
+++ b/libcxx/test/std/language.support/support.types/byteops/rshift.pass.cpp
@@ -12,6 +12,9 @@
// constexpr byte operator>>(byte b, IntType shift) noexcept;
// Constraints: is_integral_v<IntType> is true.
+// MSVC warning C4804: '>>': unsafe use of type 'bool' in operation
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4804
+
#include <cassert>
#include <cstddef>
#include <type_traits>
``````````
</details>
https://github.com/llvm/llvm-project/pull/212433
More information about the libcxx-commits
mailing list