diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2019-05-29 15:17:55 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2019-05-29 15:17:55 +0000 |
commit | 6b03a1b42352e38fafff67c6d8d685144b8f9a4c (patch) | |
tree | 7dd2b784d1e7cc724c901400f0b45afb362dde95 /libcxx/include/numeric | |
parent | c450874cb847b2c27ecc8776d39db2640627c4d0 (diff) | |
download | bcm5719-llvm-6b03a1b42352e38fafff67c6d8d685144b8f9a4c.tar.gz bcm5719-llvm-6b03a1b42352e38fafff67c6d8d685144b8f9a4c.zip |
Add additional constraints on midpoint(pointer, pointer). Fixes PR#42037.
llvm-svn: 361970
Diffstat (limited to 'libcxx/include/numeric')
-rw-r--r-- | libcxx/include/numeric | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libcxx/include/numeric b/libcxx/include/numeric index 4b08611290d..62cc29cbd6a 100644 --- a/libcxx/include/numeric +++ b/libcxx/include/numeric @@ -527,7 +527,7 @@ lcm(_Tp __m, _Up __n) #if _LIBCPP_STD_VER > 17 template <class _Tp> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp>, _Tp> +enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp> midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { @@ -548,7 +548,10 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK template <class _TPtr> _LIBCPP_INLINE_VISIBILITY constexpr -enable_if_t<is_pointer_v<_TPtr>, _TPtr> +enable_if_t<is_pointer_v<_TPtr> + && is_object_v<remove_pointer_t<_TPtr>> + && ! is_void_v<remove_pointer_t<_TPtr>> + && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr> midpoint(_TPtr __a, _TPtr __b) noexcept { return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a); |