]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/68863
authortimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2015 04:50:29 +0000 (04:50 +0000)
committertimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2015 04:50:29 +0000 (04:50 +0000)
* include/bits/regex_executor.tcc (_Executor::_M_lookahead):
Copy the captured content for lookahead, so that the backreferences
inside can refer to them.
* testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc:
New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231641 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/regex_executor.tcc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc [new file with mode: 0644]

index 5ab82ad7ee4436c9c7e19520b4fb26bbce5d429a..7f4e79787fad26f5594a3a5f1e3deee805280746 100644 (file)
@@ -1,3 +1,12 @@
+2015-12-15  Tim Shen  <timshen@google.com>
+
+       PR libstdc++/68863
+       * include/bits/regex_executor.tcc (_Executor::_M_lookahead):
+       Copy the captured content for lookahead, so that the backreferences
+       inside can refer to them.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc:
+       New testcase.
+
 2015-12-14  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Document the implementation of Logical Operator Type Traits.
index a13f0d542498c7e9f7ef94d39ea8b5ae2024a024..f5be4d7cc0616db46de04a207c2a33a093c3d958 100644 (file)
@@ -147,7 +147,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
     _M_lookahead(_StateIdT __next)
     {
-      _ResultsVec __what(_M_cur_results.size());
+      // Backreferences may refer to captured content.
+      // We may want to make this faster by not copying,
+      // but let's not be clever prematurely.
+      _ResultsVec __what(_M_cur_results);
       _Executor __sub(_M_current, _M_end, __what, _M_re, _M_flags);
       __sub._M_states._M_start = __next;
       if (__sub._M_search_from_first())
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc
new file mode 100644 (file)
index 0000000..9e7a9a7
--- /dev/null
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
+
+// libstdc++/68863
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  VERIFY(!std::regex_match("aa", std::regex("(.)(?!\\1).")));
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}