]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Compare match_results for failed regex_match
authorJonathan Wakely <jwakely@redhat.com>
Fri, 17 Dec 2021 17:58:09 +0000 (17:58 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 5 Jan 2022 13:47:00 +0000 (13:47 +0000)
The regex_match_debug testsuite helper doesn't compare the
std::match_results objects after a failed match, but it should do. The
standard says that the effects of a failed match on the match-results
are unspecified, except that [conditions testable by operator==]. So we
can check that the two sets of results compare equal even if the match
failed.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_regex.h (regex_match_debug): Compare
results even if the match failed.

libstdc++-v3/testsuite/util/testsuite_regex.h

index 6af3d8d836fac9096906428ac2047b743ee0d24f..f2bb068024d8ca0ee5b6e79cc0f1bcb5d186f3e5 100644 (file)
@@ -150,8 +150,7 @@ namespace __gnu_test
       auto __res2 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
           _RegexExecutorPolicy::_S_alternate, true>
        (__s, __e, __mm, __re, __flags);
-      // __m is unspecified if return value is false.
-      if (__res1 == __res2 && (!__res1 || __m == __mm))
+      if (__res1 == __res2 && __m == __mm)
        return __res1;
       throw std::exception();
     }