Skip to content

[libc++][hardening] Categorize more 'valid-element-access' checks. #71620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions libcxx/include/__algorithm/ranges_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ struct __fn {
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list must contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__il.begin() != __il.end(), "initializer_list must contain at least one element");

auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
Expand All @@ -69,7 +70,7 @@ struct __fn {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);

_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");

if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {
Expand Down
5 changes: 3 additions & 2 deletions libcxx/include/__algorithm/ranges_min.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct __fn {
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list must contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__il.begin() != __il.end(), "initializer_list must contain at least one element");
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
}

Expand All @@ -65,7 +66,7 @@ struct __fn {
operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
auto __first = ranges::begin(__r);
auto __last = ranges::end(__r);
_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");
if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
return *ranges::__min_element_impl(__first, __last, __comp, __proj);
} else {
Expand Down
5 changes: 3 additions & 2 deletions libcxx/include/__algorithm/ranges_minmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ struct __fn {
indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type>
operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__il.begin() != __il.end(), "initializer_list has to contain at least one element");
auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
return ranges::minmax_result<_Type>{*__iters.first, *__iters.second};
}
Expand All @@ -80,7 +81,7 @@ struct __fn {
auto __last = ranges::end(__r);
using _ValueT = range_value_t<_Range>;

_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range has to contain at least one element");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range has to contain at least one element");

if constexpr (forward_range<_Range>) {
// Special-case the one element case. Avoid repeatedly initializing objects from the result of an iterator
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__algorithm/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ _LIBCPP_HIDE_FROM_ABI _SampleIterator __sample(
_SampleIterator __output_iter,
_Distance __n,
_UniformRandomNumberGenerator& __g) {
_LIBCPP_ASSERT_UNCATEGORIZED(__n >= 0, "N must be a positive number.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "N must be a positive number.");

using _PopIterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_PopulationIterator>;
using _Difference = typename _IterOps<_AlgPolicy>::template __difference_type<_PopulationIterator>;
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__format/formatter_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ __write(_Iterator __first,
output_iterator<const iter_value_t<_Iterator>&> auto __out_it,
__format_spec::__parsed_specifications<_ParserCharT> __specs,
ptrdiff_t __size) -> decltype(__out_it) {
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");
return __formatter::__write(basic_string_view{__first, __last}, std::move(__out_it), __specs, __size);
}

Expand All @@ -259,7 +259,7 @@ __write(_Iterator __first,
_Iterator __last,
output_iterator<const iter_value_t<_Iterator>&> auto __out_it,
__format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");
return __formatter::__write(__first, __last, std::move(__out_it), __specs, __last - __first);
}

Expand All @@ -273,7 +273,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(
output_iterator<const _CharT&> auto __out_it,
__format_spec::__parsed_specifications<_ParserCharT> __specs,
_UnaryOperation __op) -> decltype(__out_it) {
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");

ptrdiff_t __size = __last - __first;
if (__size >= __specs.__width_)
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__format/parser_std_format_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
|| (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
# endif
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__begin != __end,
"when called with an empty input the function will cause "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: (hopefully helpful) All other assertion messages begin with capital letters.

Suggested change
"when called with an empty input the function will cause "
"When called with an empty input, the function will cause "

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think that this suggestion is helpful, I can put them on the others to make it easier for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It's a good suggestion, but for this PR specifically, I'd prefer to keep the delta as small as possible, even if it means leaving some less-than-perfect error messages in place. It would be good to do a follow-up to improve some messages, though.

"undefined behavior by evaluating data not in the input");
Expand Down Expand Up @@ -624,7 +624,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
template <contiguous_iterator _Iterator>
requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__begin != __end,
"when called with an empty input the function will cause "
"undefined behavior by evaluating data not in the input");
Expand Down Expand Up @@ -652,7 +652,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
// range-fill and tuple-fill are identical
template <contiguous_iterator _Iterator>
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__begin != __end,
"when called with an empty input the function will cause "
"undefined behavior by evaluating data not in the input");
Expand Down
32 changes: 16 additions & 16 deletions libcxx/include/__iterator/common_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class common_iterator {
requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent>
_LIBCPP_HIDE_FROM_ABI constexpr common_iterator(const common_iterator<_I2, _S2>& __other)
: __hold_([&]() -> variant<_Iter, _Sent> {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__other.__hold_.valueless_by_exception(), "Attempted to construct from a valueless common_iterator");
if (__other.__hold_.index() == 0)
return variant<_Iter, _Sent>{in_place_index<0>, std::__unchecked_get<0>(__other.__hold_)};
Expand All @@ -88,7 +88,7 @@ class common_iterator {
requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> &&
assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&>
_LIBCPP_HIDE_FROM_ABI common_iterator& operator=(const common_iterator<_I2, _S2>& __other) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__other.__hold_.valueless_by_exception(), "Attempted to assign from a valueless common_iterator");

auto __idx = __hold_.index();
Expand All @@ -110,15 +110,15 @@ class common_iterator {
}

_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
return *std::__unchecked_get<_Iter>(__hold_);
}

_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
requires __dereferenceable<const _Iter>
{
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
return *std::__unchecked_get<_Iter>(__hold_);
}
Expand All @@ -129,7 +129,7 @@ class common_iterator {
__i.operator->();
} || is_reference_v<iter_reference_t<_I2>> || constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
{
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {
return std::__unchecked_get<_Iter>(__hold_);
Expand All @@ -142,14 +142,14 @@ class common_iterator {
}

_LIBCPP_HIDE_FROM_ABI common_iterator& operator++() {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
++std::__unchecked_get<_Iter>(__hold_);
return *this;
}

_LIBCPP_HIDE_FROM_ABI decltype(auto) operator++(int) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
if constexpr (forward_iterator<_Iter>) {
auto __tmp = *this;
Expand All @@ -170,9 +170,9 @@ class common_iterator {
requires sentinel_for<_Sent, _I2>
_LIBCPP_HIDE_FROM_ABI friend constexpr bool
operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");

auto __x_index = __x.__hold_.index();
Expand All @@ -191,9 +191,9 @@ class common_iterator {
requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
_LIBCPP_HIDE_FROM_ABI friend constexpr bool
operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");

auto __x_index = __x.__hold_.index();
Expand All @@ -215,9 +215,9 @@ class common_iterator {
requires sized_sentinel_for<_Sent, _I2>
_LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_I2>
operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");

auto __x_index = __x.__hold_.index();
Expand All @@ -239,7 +239,7 @@ class common_iterator {
iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
requires input_iterator<_Iter>
{
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
return ranges::iter_move(std::__unchecked_get<_Iter>(__i.__hold_));
}
Expand All @@ -248,9 +248,9 @@ class common_iterator {
_LIBCPP_HIDE_FROM_ABI friend constexpr void
iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) noexcept(
noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::declval<const _I2&>()))) {
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
std::holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
return ranges::iter_swap(std::__unchecked_get<_Iter>(__x.__hold_), std::__unchecked_get<_I2>(__y.__hold_));
}
Expand Down
11 changes: 6 additions & 5 deletions libcxx/include/__iterator/counted_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ class counted_iterator
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; }

_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
_LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator is equal to or past end.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
return *__current_;
}

_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
requires __dereferenceable<const _Iter>
{
_LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator is equal to or past end.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
return *__current_;
}

Expand Down Expand Up @@ -229,7 +229,7 @@ class counted_iterator
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const
requires random_access_iterator<_Iter>
{
_LIBCPP_ASSERT_UNCATEGORIZED(__n < __count_, "Subscript argument must be less than size.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < __count_, "Subscript argument must be less than size.");
return __current_[__n];
}

Expand All @@ -253,15 +253,16 @@ class counted_iterator
iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_)))
requires input_iterator<_Iter>
{
_LIBCPP_ASSERT_UNCATEGORIZED(__i.__count_ > 0, "Iterator must not be past end of range.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i.__count_ > 0, "Iterator must not be past end of range.");
return ranges::iter_move(__i.__current_);
}

template <indirectly_swappable<_Iter> _I2>
_LIBCPP_HIDE_FROM_ABI friend constexpr void
iter_swap(const counted_iterator& __x,
const counted_iterator<_I2>& __y) noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) {
_LIBCPP_ASSERT_UNCATEGORIZED(__x.__count_ > 0 && __y.__count_ > 0, "Iterators must not be past end of range.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
__x.__count_ > 0 && __y.__count_ > 0, "Iterators must not be past end of range.");
return ranges::iter_swap(__x.__current_, __y.__current_);
}

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__ranges/subrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class _LIBCPP_TEMPLATE_VIS subrange : public view_interface<subrange<_Iter, _Sen
requires(_Kind == subrange_kind::sized)
: __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n) {
if constexpr (sized_sentinel_for<_Sent, _Iter>)
_LIBCPP_ASSERT_UNCATEGORIZED((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
"std::ranges::subrange was passed an invalid size hint");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
"std::ranges::subrange was passed an invalid size hint");
}

template <__different_from<subrange> _Range>
Expand Down
10 changes: 6 additions & 4 deletions libcxx/include/__ranges/view_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class view_interface {
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front()
requires forward_range<_D2>
{
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
return *ranges::begin(__derived());
}
Expand All @@ -118,7 +118,7 @@ class view_interface {
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const
requires forward_range<const _D2>
{
_LIBCPP_ASSERT_UNCATEGORIZED(
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
return *ranges::begin(__derived());
}
Expand All @@ -127,15 +127,17 @@ class view_interface {
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back()
requires bidirectional_range<_D2> && common_range<_D2>
{
_LIBCPP_ASSERT_UNCATEGORIZED(!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
return *ranges::prev(ranges::end(__derived()));
}

template <class _D2 = _Derived>
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const
requires bidirectional_range<const _D2> && common_range<const _D2>
{
_LIBCPP_ASSERT_UNCATEGORIZED(!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
return *ranges::prev(ranges::end(__derived()));
}

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__utility/is_pointer_in_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _T
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range(
const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
if (__libcpp_is_constant_evaluated()) {
_LIBCPP_ASSERT_UNCATEGORIZED(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range");
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range");

// If this is not a constant during constant evaluation we know that __ptr is not part of the allocation where
// [__begin, __end) is.
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/experimental/__simd/vec_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {
_Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));

_LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {
_LIBCPP_ASSERT_UNCATEGORIZED(__idx >= 0 && __idx < _Np, "Index is out of bounds");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
return __data[__idx];
}
_LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept {
_LIBCPP_ASSERT_UNCATEGORIZED(__idx >= 0 && __idx < _Np, "Index is out of bounds");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
__data[__idx] = __v;
}
};
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/support/ibm/xlocale_zos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ locale_t uselocale(locale_t newloc) {
tokenized.push_back(s);
}

_LIBCPP_ASSERT_UNCATEGORIZED(tokenized.size() >= _NCAT, "locale-name list is too short");
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(tokenized.size() >= _NCAT, "locale-name list is too short");

previous_loc->lc_collate = tokenized[LC_COLLATE];
previous_loc->lc_ctype = tokenized[LC_CTYPE];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// REQUIRES: has-unix-headers
// UNSUPPORTED: c++03, c++11, c++14, c++17
// REQUIRES: libcpp-hardening-mode={{extensive|debug}}
// UNSUPPORTED: libcpp-hardening-mode=none
// XFAIL: availability-verbose_abort-missing

#include <algorithm>
Expand Down
Loading