Subject: [Boost-bugs] [Boost C++ Libraries] #5559: interval_set works not correct with custom compare function
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-05-23 16:54:51
#5559: interval_set works not correct with custom compare function
-----------------------------+----------------------------------------------
Reporter: denis@⦠| Owner: jofaber
Type: Bugs | Status: new
Milestone: Boost 1.47.0 | Component: ICL
Version: Boost 1.46.1 | Severity: Problem
Keywords: |
-----------------------------+----------------------------------------------
Just catch a bug: interval_set works not correct with custom compare
function.
Here is the test case, it fails with boost 1.46.1 and truck version (23
May 2011, svn revision 72124).
It works ok with default std::less comparator.
Of course, it is weird to use std::greater with int as it is in this
listing.
Here is a simplified test case, I got the bug using a custom datatype
(int64_t inside) with a custom comparator.
I did not investigated it yet.
It looks like icl::succ and icl::pred should be customized together with
comparator.
{{{
#include <iostream>
#include <assert.h>
#include <boost/cstdint.hpp>
#include <boost/icl/interval_set.hpp>
int main() {
typedef boost::icl::interval_set<boost::uint32_t,
ICL_COMPARE_INSTANCE(std::greater, boost::uint32_t)> Set;
Set q1( Set::interval_type::closed(UINT32_MAX, 0) );
Set q2( Set::interval_type::closed(1000, 100) );
Set q3( Set::interval_type::closed(1, 1) );
Set q4( Set::interval_type::closed(1, 0) );
Set q5( Set::interval_type::closed(0, 0) );
std::cout << q1 << " + " << q2 << " = " << (q1+q2) << std::endl; // ok
std::cout << q1 << " + " << q3 << " = " << (q1+q3) << std::endl; //
incorrect result
std::cout << q1 << " + " << q4 << " = " << (q1+q4) << std::endl; //
incorrect result
std::cout << q1 << " + " << q5 << " = " << (q1+q5) << std::endl; //
assertion inside icl
assert(q1 == q1+q2);
assert(q1 == q1+q3);
assert(q1 == q1+q4);
assert(q1 == q1+q5);
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5559> 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:06 UTC