aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-12-30 11:40:37 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-12-30 11:40:37 +0000
commitf32fd5aaecb0673c9cdaf5a4f8fe6bbe1e9049a7 (patch)
treefc2bb9ee186278412ea91cffe0be6b04225d3390
parente6386103dd175120883639c83ca539bc53fd9c98 (diff)
downloadgcc-f32fd5aaecb0673c9cdaf5a4f8fe6bbe1e9049a7.zip
gcc-f32fd5aaecb0673c9cdaf5a4f8fe6bbe1e9049a7.tar.gz
gcc-f32fd5aaecb0673c9cdaf5a4f8fe6bbe1e9049a7.tar.bz2
re PR libstdc++/51711 (regex.h contains incorrect code)
2011-12-30 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/51711 * include/bits/regex.h (regex_replace): Fix thinko. * testsuite/28_regex/algorithms/regex_replace/char/51711.cc: New. * testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc: Likewise. From-SVN: r182740
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/regex.h2
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/51711.cc31
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc31
4 files changed, 71 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7a35a3a..09615cb 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2011-12-30 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/51711
+ * include/bits/regex.h (regex_replace): Fix thinko.
+ * testsuite/28_regex/algorithms/regex_replace/char/51711.cc: New.
+ * testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc:
+ Likewise.
+
2011-12-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/hashtable_policy.h (struct _Ebo_helper<>): Don't use
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 645011d..4c49665 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -2223,7 +2223,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_constants::match_flag_type __flags
= regex_constants::match_default)
{
- std::string __result;
+ basic_string<_Ch_type> __result;
regex_replace(std::back_inserter(__result),
__s.begin(), __s.end(), __e, __fmt, __flags);
return __result;
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/51711.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/51711.cc
new file mode 100644
index 0000000..5532713
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/51711.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 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/>.
+//
+
+#include <regex>
+#include <string>
+
+// libstdc++/51711
+void test01()
+{
+ std::string toProcess("Bug\r\n");
+ std::string result __attribute__((unused))
+ = std::regex_replace(toProcess, std::regex("\\r"), std::string("\\r"));
+}
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc
new file mode 100644
index 0000000..66b74e4
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 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/>.
+//
+
+#include <regex>
+#include <string>
+
+// libstdc++/51711
+void test01()
+{
+ std::wstring toProcess(L"Bug\r\n");
+ std::wstring result __attribute__((unused))
+ = std::regex_replace(toProcess, std::wregex(L"\\r"), std::wstring(L"\\r"));
+}