public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ryanmolden at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug other/51711] New: regex.h contains incorrect code Date: Fri, 30 Dec 2011 06:09:00 -0000 [thread overview] Message-ID: <bug-51711-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51711 Bug #: 51711 Summary: regex.h contains incorrect code Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned@gcc.gnu.org ReportedBy: ryanmolden@gmail.com The code in regex_replace looks like this template <typename _Rx_traits, typename _Ch_type> inline basic_string<_Ch_type> regex_replace(const basic_string<_Ch_type>& __s, const basic_regex<_Ch_type, _Rx_traits>& __e, const basic_string<_Ch_type>& __fmt, regex_constants::match_flag_type __flags, = regex_constants::match_default) { std::string __result; regex_replace(std::back_inserter(__result), __s.begin(), __s.end(), __e, __fmt, __flags); return __result; } However, the std::string is incorrect if you are attempting to use wstring and wregex here (which should be allowed by all the other code which goes to pains to use basic_string<_Ch_type>). This code repros the bug: #include <regex> #include <string> int main(int argc, char **argv) { std::wstring toProcess(L"Bug\r\n"); std::wstring result = std::regex_replace(toProcess, std::wregex(L"\\r"), std::wstring(L"\\r")); return 0; } compiled with: g++ <filename> -std=c++0x +Wall In file included from /usr/include/c++/4.6/regex:62:0, from Test.cpp:1: /usr/include/c++/4.6/bits/regex.h: In function std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) [with _Rx_traits = std::regex_traits<wchar_t>, _Ch_type = wchar_t, std::regex_constants::match_flag_type = std::bitset<11ul>]: Test.cpp:7:96: instantiated from here /usr/include/c++/4.6/bits/regex.h:2225:14: error: could not convert __result from std::string {aka std::basic_string<char>} to std::basic_string<wchar_t> on Ubuntu 11.10 Server 64 bit edition with GCC 4.6.1
next reply other threads:[~2011-12-30 6:08 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-12-30 6:09 ryanmolden at gmail dot com [this message] 2011-12-30 6:16 ` [Bug libstdc++/51711] " pinskia at gcc dot gnu.org 2011-12-30 10:59 ` paolo.carlini at oracle dot com 2011-12-30 11:41 ` paolo at gcc dot gnu.org 2011-12-30 11:42 ` paolo at gcc dot gnu.org 2011-12-30 12:37 ` paolo.carlini at oracle dot com
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=bug-51711-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).