public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Compare match_results for failed regex_match
Date: Wed,  5 Jan 2022 13:47:49 +0000	[thread overview]
Message-ID: <20220105134749.1639763-1-jwakely@redhat.com> (raw)

Tested powerpc64le-linux, pushed to trunk.


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 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/util/testsuite_regex.h b/libstdc++-v3/testsuite/util/testsuite_regex.h
index 6af3d8d836f..f2bb068024d 100644
--- a/libstdc++-v3/testsuite/util/testsuite_regex.h
+++ b/libstdc++-v3/testsuite/util/testsuite_regex.h
@@ -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();
     }
-- 
2.31.1


                 reply	other threads:[~2022-01-05 13:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220105134749.1639763-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).