Boost C++ Libraries: Ticket #652: Still assertion failure in boost::format for empty strings https://svn.boost.org/trac10/ticket/652 <pre class="wiki">The assertion failure of boost::format in case of empty string arguments that occured since VS2005 has been partly fixed by cepstein in March 2006. This fix was partial, because there still exists a corner case, where this assertion can take place: #include &lt;iostream&gt; #include &lt;ostream&gt; #include &lt;string&gt; #include &lt;boost/format.hpp&gt; int main() { std::string arg; // empty string boost::format fmt = boost::format("%=8s") % arg; std::string s = fmt.str(); std::cout &lt;&lt; s &lt;&lt; std::endl; } The proposed patch looks in unified syntax: Index: feed_args.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/format/feed_args.hpp,v retrieving revision 1.29 diff -u -r1.29 feed_args.hpp --- feed_args.hpp 22 Mar 2006 15:13:25 -0000 1.29 +++ feed_args.hpp 15 Jun 2006 19:49:37 -0000 @@ -63,7 +63,8 @@ if(n_before) res.append(n_before, fill_char); if(prefix_space) res.append(1, prefix_space); - res.append(beg, size); + if (size) + res.append(beg, size); if(n_after) res.append(n_after, fill_char); } } // -mk_str(..) and in standard syntax: Index: feed_args.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/format/feed_args.hpp,v retrieving revision 1.29 diff -r1.29 feed_args.hpp 66c66,67 &lt; res.append(beg, size); --- &gt; if (size) &gt; res.append(beg, size); </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/652 Trac 1.4.3 joaquintides Mon, 19 Jun 2006 06:24:57 GMT <link>https://svn.boost.org/trac10/ticket/652#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/652#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=911241 Applied fixes according to Daniel's instructions </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>joaquintides</dc:creator> <pubDate>Mon, 19 Jun 2006 06:24:58 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/652#comment:2 https://svn.boost.org/trac10/ticket/652#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket