id summary reporter owner description type status milestone component version severity resolution keywords cc 565 rational::operator< fails for unsigned value types dbenbenn Jonathan Turkanis "{{{ There's a minor bug in rational.hpp when using unsigned values. Consider the following simple program: int main(void) { boost::rational x = 0; assert(x.operator<(1)); } The assertion fails. The reason is that in rational.hpp::rational::operator< (param_type i) are the lines if (num > zero) return (num/den) < i; else return -i < (-num/den); The last line is bogus for unsigned types if num == 0 and i > 0. The problem can be fixed by changing (num > zero) to (num >= zero). Another issue with the same section of code is that it uses up to 5 comparisons of IntType values. Attached is a patch that fixes the bug described, and also makes the function only perform up to 3 comparisons. That can make a difference, of course, if IntType is a complicated type with a slow comparison operator. }}}" Patches closed None None Fixed