[libcxx-commits] [libcxx] [libc++][hardening] Categorize more assertions. (PR #75918)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 4 19:14:17 PST 2024
================
@@ -4587,28 +4587,36 @@ public:
// element access:
_LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const {
- _LIBCPP_ASSERT_UNCATEGORIZED(ready(), "match_results::length() called when not ready");
+ // If the match results are not ready, this will return `0`.
+ _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::length() called when not ready");
return (*this)[__sub].length();
----------------
var-const wrote:
Surprisingly enough, if I'm reading the [preconditions](https://en.cppreference.com/w/cpp/regex/match_results/length) correctly, all possible values are valid:
> If `n == 0`, the length of the entire matched expression is returned.
> If `n > 0 && n < size()`, the length of nth sub-match is returned.
> if `n >= size()`, a length of the unmatched match is returned.
https://github.com/llvm/llvm-project/pull/75918
More information about the libcxx-commits
mailing list