]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::match_results::end() for failed matches [PR102667]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Oct 2021 08:07:15 +0000 (09:07 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 11 Oct 2021 19:34:16 +0000 (20:34 +0100)
commit84088dc4bb6a546c896a068dc201463493babf43
tree1b9cda7ec87970a26092a41745ce184fd3907ce6
parent008e7397dad971c03c08fc1b0a4a98fddccaaed8
libstdc++: Fix std::match_results::end() for failed matches [PR102667]

The end() function needs to consider whether the underlying vector is
empty, not whether the match_results object is empty. That's because the
underlying vector will always contain at least three elements for a
match_results object that is "ready". It contains three extra elements
which are stored in the vector but are not considered part of sequence,
and so should not be part of the [begin(),end()) range.

libstdc++-v3/ChangeLog:

PR libstdc++/102667
* include/bits/regex.h (match_result::empty()): Optimize by
calling the base function directly.
(match_results::end()): Check _Base_type::empty() not empty().
* testsuite/28_regex/match_results/102667.C: New test.
libstdc++-v3/include/bits/regex.h
libstdc++-v3/testsuite/28_regex/match_results/102667.C [new file with mode: 0644]