#11803 closed Bugs (fixed)
Fails with closed intervals fails in some border cases.
Reported by: | Owned by: | Joachim Faulhaber | |
---|---|---|---|
Milestone: | To Be Determined | Component: | ICL |
Version: | Boost 1.59.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
ICL seems not to handle sets that contain the maximum element of the domain type. I have attached a file that shows the problem.
The problem is in the fie \boost\icl\concept\interval.hpp (line 1145) in the left_subtract.
It should look like this:
template<class Type> typename boost::enable_if<is_static_closed<Type>, Type>::type left_subtract(Type right, const Type& left_minuend) { if(exclusive_less(left_minuend, right)) return right; else if(upper_less_equal(right, left_minuend)) return identity_element<Type>::value(); return construct<Type>(domain_next<Type>(upper(left_minuend)), upper(right)); }
Where as it actually looks like this:
template<class Type> typename boost::enable_if<is_static_closed<Type>, Type>::type left_subtract(Type right, const Type& left_minuend) { if(exclusive_less(left_minuend, right)) return right; return construct<Type>(domain_next<Type>(upper(left_minuend)), upper(right)); }
The right subtract function is ok.
The comment for the left_subtract functions is also wrong. "Return the difference: The part of \c right right of \c left_minuend."
The word "right" in BOLD should read "left".
Attachments (1)
Change History (7)
by , 7 years ago
Attachment: | icl_question.cpp added |
---|
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Correction: The comment for left_subtract is correct and should read as is ("The part of \c right right of \c left_minuend."). It's the comment for right_subtract that's wrong. It reads "Return the difference: The part of \c left right of \c right_minuend." the word in boldshould read "left".
Clarification: The extra check I added is already present in right_subtract so efficiency arguments seem not to apply.
comment:3 by , 7 years ago
It's been mention in mailing list that "You can use icl interval containers with limited integral numeric domain-types safely on intervals using values from ++std::min<T>() to--std::max<T>()".
If this is the case then even code such as this is illegal:
boost::interval_set<unsigned int> int(0, 10);
This seems unacceptable. And as mentioned above the code in right_subtract already guards against this.
follow-up: 5 comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 6 comment:5 by , 7 years ago
Replying to jofaber: I'm new to the boost svn repo and such, but I can't see any changes. The obvious question is does "Resolution set to fixed" mean changes were made to fix this issue, or, that no changes were made because this it is not considered a problem?
comment:6 by , 7 years ago
Replying to shewitt.au@…:
Replying to jofaber: I'm new to the boost svn repo and such, but I can't see any changes. The obvious question is does "Resolution set to fixed" mean changes were made to fix this issue, or, that no changes were made because this it is not considered a problem?
The changes were made to the develop branch on modular-boost https://github.com/boostorg/icl/blob/develop/include/boost/icl/concept/interval.hpp
From there it will be merged to master after regression tests are being checked.
Here's the output of the sample program: