[PATCH] D70099: [libcxx][test] Only call valarray::min and ::max on empty containers when testing libc++
Casey Carter via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 11 13:25:41 PST 2019
CaseyCarter created this revision.
CaseyCarter added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.
`valarray:min` and `valarray::max` have preconditions that require the `valarray` to be non-empty, so these calls are inherently non-portable.
https://reviews.llvm.org/D70099
Files:
test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
Index: test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
===================================================================
--- test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -26,11 +26,13 @@
std::valarray<T> v1(a1, N1);
assert(v1.min() == -3.0);
}
+#ifdef _LIBCPP_VERSION // Not portable: valarray::min requires size() >
{
typedef double T;
std::valarray<T> v1;
v1.min();
}
+#endif // _LIBCPP_VERSION
{
typedef double T;
T a1[] = {1.5, 2.5, -3, 4, 5.5};
@@ -39,5 +41,5 @@
assert((2*v1).min() == -6.0);
}
- return 0;
+ return 0;
}
Index: test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
===================================================================
--- test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
+++ test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -26,11 +26,13 @@
std::valarray<T> v1(a1, N1);
assert(v1.max() == 4.0);
}
+#ifdef _LIBCPP_VERSION // Not portable: valarray::max requires size() > 0
{
typedef double T;
std::valarray<T> v1;
v1.max();
}
+#endif // _LIBCPP_VERSION
{
typedef double T;
T a1[] = {1.5, 2.5, -3, 4, -5.5};
@@ -39,5 +41,5 @@
assert((2*v1).max() == 8.0);
}
- return 0;
+ return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70099.228764.patch
Type: text/x-patch
Size: 1543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191111/d25170c4/attachment.bin>
More information about the cfe-commits
mailing list