Boost C++ Libraries: Ticket #6680: Compilation error at regex file basic_regex_parser.hpp https://svn.boost.org/trac10/ticket/6680 <p> Hi, </p> <p> Compile boost 1.49.0 on Sun SPARC 5.10 using Sun Studio 12 yield compilation error on file "basic_regex_parser.hpp". </p> <p> Line 208 of that file contains the following: </p> <blockquote> <p> message += std::string(m_base + start_pos, m_base + position); message += "&gt;&gt;&gt;HERE&gt;&gt;&gt;"; message += std::string(m_base + position, m_base + end_pos); </p> </blockquote> <p> where m_base, poition, start_pos and end_pos defined as: const charT* m_base; std::ptrdiff_t position, std::string message, std::ptrdiff_t start_pos </p> <p> The problem occurs when compile the regex source file "wide_posix_api.cpp" which indirectly include the file "basic_regex_parser.hpp". </p> <p> It look like the above code attempts to constructs a nice std::string error message providing it a small piece of the regex, which in this case is of wide string type (i.e., construct stdd:string using wchar_t*). </p> <p> The existent nearest constructor: basic_string (const _charT*, const _charT*, const _Allocator&amp; _RWSTD_DEFAULT_ARG(_Allocator())); </p> <p> where "_charT" is either "char" or "wchar_t", right?! </p> <p> You can have: 1) basic_string&lt;char&gt;(char* b, char* e) 2) basic_string&lt;wchar_t&gt;(wchar_t* b, wchar_t* e) </p> <p> But definitively not: basic_string&lt;char&gt;(wchar_t* b, wchar_t* e) This is a MISHMASH. </p> <p> (what error message will be look like if it start as a std::string, than you concat it piece of wide string, and and end is with a std::string? it will be garbaged). </p> <p> Here is the compilation error: </p> <p> miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; pwd /VOBS/n2_3rd_party_components/boost/dev/boost_1_49_0/libs/regex/src miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; CC -V CC: Sun C++ 5.12 SunOS_sparc 2011/11/16 miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; CC -c -g -I../../.. wide_posix_api.cpp "../../../boost/regex/v4/basic_regex_parser.hpp", line 208: Error: Could not find a match for std::string::basic_string(const wchar_t*, const wchar_t*) needed in boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::fail(boost::regex_constants::error_type, int, std::string, int). "../../../boost/regex/v4/basic_regex_parser.hpp", line 51: Where: While instantiating "boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::fail(boost::regex_constants::error_type, int, std::string, int)". "../../../boost/regex/v4/basic_regex_parser.hpp", line 51: Where: Instantiated from boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::parse(const wchar_t*, const wchar_t*, unsigned). "../../../boost/regex/v4/basic_regex.hpp", line 212: Where: Instantiated from boost::basic_regex&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::do_assign(const wchar_t*, const wchar_t*, unsigned). "../../../boost/regex/v4/basic_regex.hpp", line 379: Where: Instantiated from non-template code. "../../../boost/regex/v4/basic_regex_parser.hpp", line 210: Error: Could not find a match for std::string::basic_string(const wchar_t*, const wchar_t*) needed in boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::fail(boost::regex_constants::error_type, int, std::string, int). "../../../boost/regex/v4/basic_regex_parser.hpp", line 51: Where: While instantiating "boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::fail(boost::regex_constants::error_type, int, std::string, int)". "../../../boost/regex/v4/basic_regex_parser.hpp", line 51: Where: Instantiated from boost::re_detail::basic_regex_parser&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::parse(const wchar_t*, const wchar_t*, unsigned). "../../../boost/regex/v4/basic_regex.hpp", line 212: Where: Instantiated from boost::basic_regex&lt;wchar_t, boost::c_regex_traits&lt;wchar_t&gt;&gt;::do_assign(const wchar_t*, const wchar_t*, unsigned). "../../../boost/regex/v4/basic_regex.hpp", line 379: Where: Instantiated from non-template code. 2 Error(s) detected. Exit 2 miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; miko@compile1-U10-zone<a href="https://svn.boost.org/trac10/&lt;5&gt;libs/regex/src">&lt;5&gt;libs/regex/src</a> &gt; </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6680 Trac 1.4.3 John Maddock Sun, 08 Jul 2012 07:54:37 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6680#comment:1 https://svn.boost.org/trac10/ticket/6680#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79342" title="Add workaround for old broken compilers that don't support template ...">[79342]</a>) Add workaround for old broken compilers that don't support template construct/assign to containers. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6680" title="#6680: Bugs: Compilation error at regex file basic_regex_parser.hpp (closed: fixed)">#6680</a>. </p> Ticket