[Boost-bugs] [Boost C++ Libraries] #10949: crash in boost.format, vs2013, /RTCc, x86

Subject: [Boost-bugs] [Boost C++ Libraries] #10949: crash in boost.format, vs2013, /RTCc, x86
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-21 16:32:17


#10949: crash in boost.format, vs2013, /RTCc, x86
--------------------------------------+---------------------------
 Reporter: david x callaway <dxc@…> | Owner: samuel_krempp
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: format
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
--------------------------------------+---------------------------
 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);
      }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10949>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC