Fix unsound numeric_minimum bounds and add symmetric numeric_maximum#59
Open
gl84 wants to merge 1 commit into
Open
Fix unsound numeric_minimum bounds and add symmetric numeric_maximum#59gl84 wants to merge 1 commit into
gl84 wants to merge 1 commit into
Conversation
…guards numeric_minimum relied solely on is_numeric<T>::value to decide whether to query std::numeric_limits<T>. For types where is_numeric is true but numeric_limits is not specialized (e.g. boost::rational), min()/max() silently fall back to a default-constructed T(), producing wrong bound checks (boostorg#58). It also used min() for the lower extreme, which for non-integral types is the smallest *positive* value rather than the most negative one. Changes: - Guard all bound checks on std::numeric_limits<T>::is_specialized; unspecialized numeric domains now impose no constraint instead of comparing against a bogus default-constructed bound. - Use lowest() (not min()) for the lower extreme. - Add a numeric_maximum trait mirroring numeric_minimum to detect domain_next overflow, and assert it wherever an interval boundary is built via domain_next (singleton, unit_trail, hull) and in first(), making first()/last() symmetric. - Add regression tests for the bound traits (int, double, rational) and for first()/last() across all bound flavors. Fixes boostorg#58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
numeric_minimum relied solely on is_numeric::value to decide whether to query std::numeric_limits. For types where is_numeric is true but numeric_limits is not specialized (e.g. boost::rational), min()/max() silently fall back to a default-constructed T(), producing wrong bound checks (#58). It also used min() for the lower extreme, which for non-integral types is the smallest positive value rather than the most negative one.
Changes:
Fixes #58