Boost C++ Libraries: Ticket #10949: crash in boost.format, vs2013, /RTCc, x86 https://svn.boost.org/trac10/ticket/10949 <p> win 7/64, boost-1.57.0, compiled to 32 bit note: this bug has been here since at least boost-1.48. </p> <p> code: </p> <pre class="wiki">// compile cl -I/path/to/boost -EHsc -Od -RTCc t.cpp #include "boost/format.hpp" #include &lt;string&gt; int main(int argc, const char** argv) { const int i(200); std::string s(boost::str(boost::format("x:%1%,y]")%i)); return 0; } </pre><p> what happens: runtime check fails at feed_args.cpp:200 (cast of an <span class="underline">int64 to unsigned int). </span></p> <p> proposed patch: </p> <pre class="wiki">diff -Naur format.orig/internals.hpp format/internals.hpp --- format.orig/internals.hpp Mon May 12 11:06:18 2014 +++ format/internals.hpp Wed Jan 21 05:19:28 2015 @@ -76,7 +76,7 @@ typedef ::std::basic_string&lt;Ch, Tr, Alloc&gt; string_type; format_item(Ch fill) :argN_(argN_no_posit), fmtstate_(fill), - truncate_(max_streamsize()), pad_scheme_(0) {} + truncate_(static_cast&lt;size_t&gt;(-1)), pad_scheme_(0) {} void reset(Ch fill); void compute_states(); // sets states according to truncate and pad_scheme. @@ -164,7 +164,7 @@ template&lt;class Ch, class Tr, class Alloc&gt; void format_item&lt;Ch, Tr, Alloc&gt;:: reset (Ch fill) { - argN_=argN_no_posit; truncate_ = max_streamsize(); pad_scheme_ =0; + argN_=argN_no_posit; truncate_ = static_cast&lt;size_t&gt;(-1); pad_scheme_ =0; res_.resize(0); appendix_.resize(0); fmtstate_.reset(fill); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10949 Trac 1.4.3 James E. King, III Thu, 12 Oct 2017 18:29:22 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10949#comment:1 https://svn.boost.org/trac10/ticket/10949#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">duplicate</span> </li> </ul> <p> Duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4636" title="#4636: Bugs: Run-Time Check Failure #1 in feed_args.hpp using Visual Studio 2010 (closed: fixed)">#4636</a> </p> Ticket