Repository navigation
fix: unsigned integer axis maps values below start to overflow - #447
Open
vera-rubin wants to merge 1 commit into
Open
vera-rubin wants to merge 1 commit into
vera-rubin wants to merge 1 commit into
Conversation
integer::index() computed x - min_ in the value type before converting to double. For an unsigned value type and x < min_ this wraps around to a large positive number, so axis::integer<unsigned>(1, 4) put 0 into the overflow bin instead of the underflow bin, and a circular unsigned axis returned the wrong bin. Compute min_ - x and negate it in that case. Signed and floating point value types are unchanged. Fixes boostorg#446
This branch has not been deployed
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.
For
unsigned,integer::index()evaluatedx - min_before converting todouble. Whenx < min_, wrapping madeaxis::integer<unsigned>(1, 4)count0uas overflow instead of underflow, and its circular variant returned bin 0 instead of bin 2.We negate
min_ - xfor unsignedx < min_. Signed and floating-point subtraction and growing-axisupdate()are unchanged.We added a regression in
test/axis_integer_test.cpp: plain and circular unsigned[1, 4)axes fail base, pass fix with both compilers. GCC standalone CMakecheckpassed 89/89 before and after. Axis builds passed C++17-Wall -Wextra -Werrorand C++14/C++20-Wconversion -Wsign-conversion -Werror. GCC C++14/C++20 passed ASan and UBSan.Version: base
developatf9017f94684583eeef80eb230768c932a8a6e76c, GCC 13.3.0, Clang 18.1.3, x86-64 Linux.Fixes #446
— ChipLab