[Boost-bugs] [Boost C++ Libraries] #2228: signed overflow problem in weighted_sum on VC9.0

Subject: [Boost-bugs] [Boost C++ Libraries] #2228: signed overflow problem in weighted_sum on VC9.0
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-08-19 15:57:57


#2228: signed overflow problem in weighted_sum on VC9.0
--------------------------+-------------------------------------------------
 Reporter: pavol_droba | Owner: eric_niebler
     Type: Bugs | Status: new
Milestone: Boost 1.36.0 | Component: accumulator
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 Hi,

 I have spotted rather unexpected behaviour while using weighted_sum.

 Here is the simple code:
 {{{
 // use namespaces
 using namespace boost::accumulators;
 using namespace std;

 // create a int accumulator with std::size_t weight
 accumulator_set<int, features<tag::weighted_sum>, std::size_t> Accum;

 // Accumulate negative value with positive weight
 Accum(-56, boost::accumulators::weight=3);

 // Print the output
 wcout << "sum: " << boost::accumulators::weighted_sum(Accum) << endl;
 }}}

 I was expecting to get result -168, however I got 4294967128.

 I have traced the problem to weighted_sum_impl.

 I don't know why, but
 {{{
 weighted_sum_impl<int, unsigned int, tag::sample>::weighted_sample
 }}}

 is resolved to {{{unsigned int}}}. I think this is plain wrong.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2228>
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:49:58 UTC