[libcxx-commits] [PATCH] D131854: [libc++][test] fix C4267 warning in bitset.members\to_ulong.pass.cpp
Igor Zhukov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Aug 14 03:37:05 PDT 2022
fsb4000 created this revision.
fsb4000 added a reviewer: philnik.
fsb4000 added a project: libc++.
Herald added a project: All.
fsb4000 requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
warning C4267: 'initializing': conversion from 'size_t' to 'unsigned long', possible loss of data
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131854
Files:
libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
Index: libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
===================================================================
--- libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
+++ libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -33,8 +33,9 @@
std::min(max, max-1),
max
};
- for (unsigned long j : tests) {
- std::bitset<N> v(j);
+ for (std::size_t j_ : tests) {
+ unsigned long j = static_cast<unsigned long>(j_); // avoid compiler warnings
+ std::bitset<N> v(j);
assert(j == v.to_ulong());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131854.452506.patch
Type: text/x-patch
Size: 643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220814/ac242f8e/attachment.bin>
More information about the libcxx-commits
mailing list