[PATCH] D21583: [libcxx] [test] Make unord.hash/integral.pass.cpp portable.
Stephan T. Lavavej via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 21 17:54:19 PDT 2016
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
Make unord.hash/integral.pass.cpp portable.
This was assuming identity hashing, which is a non-Standard assumption. Guarding this with LIBCPP_ASSERT makes the test portable.
Also fixes MSVC warning C4805 "'==': unsafe mix of type '::size_t' and type 'bool' in operation".
http://reviews.llvm.org/D21583
Files:
test/std/utilities/function.objects/unord.hash/integral.pass.cpp
Index: test/std/utilities/function.objects/unord.hash/integral.pass.cpp
===================================================================
--- test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -16,14 +16,14 @@
// size_t operator()(T val) const;
// };
-// Not very portable
-
#include <functional>
#include <cassert>
#include <type_traits>
#include <cstddef>
#include <limits>
+#include "test_macros.h"
+
template <class T>
void
test()
@@ -37,7 +37,11 @@
{
T t(i);
if (sizeof(T) <= sizeof(std::size_t))
- assert(h(t) == t);
+ {
+ const std::size_t result = h(t);
+ LIBCPP_ASSERT(result == t);
+ ((void)result); // Prevent unused warning
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21583.61476.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160622/b3684be9/attachment.bin>
More information about the cfe-commits
mailing list