summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex
diff options
context:
space:
mode:
authortimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-09 22:11:32 +0000
committertimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-09 22:11:32 +0000
commitfc75f6e7715eb88abddf98d0c2fce4125efd863e (patch)
tree0e81d112ff6e0f52f5581c22bc26db396d352b6d /libstdc++-v3/testsuite/28_regex
parent3ae06f68944bc562c776b65f04e7af674f4bd512 (diff)
downloadgcc-fc75f6e7715eb88abddf98d0c2fce4125efd863e.tar.gz
* libstdc++-v3/include/bits/regex.h (regex_iterator::regex_iterator()):
Define end() as _M_pregex == nullptr. * libstdc++-v3/include/bits/regex.tcc (regex_iterator::operator==(), regex_iterator::operator++()): Fix operator==() and operator++() to look at null-ness of _M_pregex on both sides. * testsuite/28_regex/regression.cc: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242025 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex')
-rw-r--r--libstdc++-v3/testsuite/28_regex/regression.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/regression.cc b/libstdc++-v3/testsuite/28_regex/regression.cc
index effb356075e..5214fe3dbc2 100644
--- a/libstdc++-v3/testsuite/28_regex/regression.cc
+++ b/libstdc++-v3/testsuite/28_regex/regression.cc
@@ -72,6 +72,27 @@ test05()
VERIFY(regex_match_debug("-", std::regex("[a-]")));
}
+// PR libstdc++/78236
+void
+test06()
+{
+ char const s[] = "afoo";
+ std::basic_regex<char> r("(f+)");
+ {
+ std::cregex_iterator i(s, s+sizeof(s), r);
+ std::cregex_iterator j(s, s+sizeof(s), r);
+ VERIFY(i == j);
+ }
+ // The iterator manipulation code must be repeated in the same scope
+ // to expose the undefined read during the execution of the ==
+ // operator (stack location reuse)
+ {
+ std::cregex_iterator i(s, s+sizeof(s), r);
+ std::cregex_iterator j;
+ VERIFY(!(i == j));
+ }
+}
+
int
main()
{
@@ -80,6 +101,7 @@ main()
test03();
test04();
test05();
+ test06();
return 0;
}