Boost C++ Libraries: Ticket #4261: bug? with boost::find_format_all, boost::regex_finder and custom regex formatter. I'm not sure. https://svn.boost.org/trac10/ticket/4261 <p> I have a code that has been working for almost 4 years (since boost 1.33) and today I went from boost 1.36 to boost 1.42 and now I have a problem. </p> <p> I'm calling a custom formatter on a string to format parts of the string that match a REGEX. </p> <p> For instance, a string like: "abc;def:&#34; will be changed to &#34;abc\2Cdef\3B" if the REGEX contains "([;:])" </p> <p> boost::find_format_all( mystring, boost::regex_finder( REGEX ), custom_formatter() ); </p> <p> The custom formatter looks like this: </p> <p> struct custom_formatter() { </p> <blockquote> <p> template&lt; typename T &gt; std::string operator()( const T &amp; s ) const { </p> <blockquote> <p> std::string matchStr = s.match_results().str(1); </p> </blockquote> </blockquote> <blockquote> <blockquote> <p> <em> perform substitutions </em></p> </blockquote> </blockquote> <blockquote> <blockquote> <p> return matchStr; </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> This worked fine but with boost 1.42 I now have "non initialized" s.match_results() which yield to boost::exception_detail::clone_implINS0_::error_info_injectorISt11logic_errorEEEE - Attempt to access an uninitialzed boost::match_results&lt;&gt; class. </p> <p> This means that sometimes I am in the functor to format a string but there is no match. It seems I have a new empty match at the end of each string to parse. </p> <p> Am I doing something wrong? Or is it normal to enter the functor when there is no match and I should check against something? </p> <p> I can avoid this testing s.begin() == s.end() at the begining of the functor, but is it really necessary or is it a bug </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4261 Trac 1.4.3 Steven Watanabe Thu, 27 May 2010 03:35:16 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4261#comment:1 https://svn.boost.org/trac10/ticket/4261#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Pavol Droba</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">string_algo</span> </li> </ul> <p> This sounds like a bug to me. </p> Ticket Éric Malenfant <eric.malenfant@…> Thu, 27 May 2010 13:21:14 GMT <link>https://svn.boost.org/trac10/ticket/4261#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4261#comment:2</guid> <description> <p> This looks very much like Ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2777" title="#2777: Bugs: find_format_all calls formatter with invalid match (closed: fixed)">#2777</a> :"find_format_all calls formatter with invalid match". </p> <p> An interesting difference is that the present ticket reports that the problem was absent in Boost 1.36, while ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2777" title="#2777: Bugs: find_format_all calls formatter with invalid match (closed: fixed)">#2777</a> is filed against Boost 1.35. </p> </description> <category>Ticket</category> </item> <item> <author>nic.bertrand@…</author> <pubDate>Thu, 27 May 2010 17:04:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4261#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4261#comment:3</guid> <description> <p> I've test quickly with boost 1.39 and the bug is not present </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Wed, 09 Jun 2010 22:53:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4261#comment:4 https://svn.boost.org/trac10/ticket/4261#comment:4 <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">duplicate</span> </li> </ul> <p> Duplicates <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2777" title="#2777: Bugs: find_format_all calls formatter with invalid match (closed: fixed)">#2777</a>. </p> Ticket