Opened 8 years ago
Closed 5 years ago
#10949 closed Bugs (duplicate)
crash in boost.format, vs2013, /RTCc, x86
Reported by: | Owned by: | Samuel Krempp | |
---|---|---|---|
Milestone: | To Be Determined | Component: | format |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | Cc: |
Description
win 7/64, boost-1.57.0, compiled to 32 bit note: this bug has been here since at least boost-1.48.
code:
// compile cl -I/path/to/boost -EHsc -Od -RTCc t.cpp #include "boost/format.hpp" #include <string> int main(int argc, const char** argv) { const int i(200); std::string s(boost::str(boost::format("x:%1%,y]")%i)); return 0; }
what happens: runtime check fails at feed_args.cpp:200 (cast of an int64 to unsigned int).
proposed patch:
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<Ch, Tr, Alloc> string_type; format_item(Ch fill) :argN_(argN_no_posit), fmtstate_(fill), - truncate_(max_streamsize()), pad_scheme_(0) {} + truncate_(static_cast<size_t>(-1)), pad_scheme_(0) {} void reset(Ch fill); void compute_states(); // sets states according to truncate and pad_scheme. @@ -164,7 +164,7 @@ template<class Ch, class Tr, class Alloc> void format_item<Ch, Tr, Alloc>:: reset (Ch fill) { - argN_=argN_no_posit; truncate_ = max_streamsize(); pad_scheme_ =0; + argN_=argN_no_posit; truncate_ = static_cast<size_t>(-1); pad_scheme_ =0; res_.resize(0); appendix_.resize(0); fmtstate_.reset(fill); }
Note:
See TracTickets
for help on using tickets.
Duplicate of #4636