Fixed potential bug with -MINIMUM_VALUE #1

Merged
EnilPajic merged 3 commits from patch-1-negative-minimum-value into master 4 years ago
EnilPajic commented 4 years ago (Migrated from github.com)

Original code had something like N < 0 ? -N : N which could fail if N has minimum value of appropriate type. For example, in original code this could fail:

const long long int LL_MIN = std::numeric_limits<long long int>::min(); //probably: -9223372036854775808
static const char *number = to_string<LL_MIN, 10>;

Also note that this code relies on "modulo on negative first operands" which was implementation defined in C++03 and before, but with C++11 and later it is defined by standard (see ISO14882:2011(e)), and this code anyway targets C++17 so we're safe here.

Original code had something like `N < 0 ? -N : N` which could fail if `N` has minimum value of appropriate type. For example, in original code this could fail: ```cpp const long long int LL_MIN = std::numeric_limits<long long int>::min(); //probably: -9223372036854775808 static const char *number = to_string<LL_MIN, 10>; ``` Also note that this code relies on "modulo on negative first operands" which was implementation defined in C++03 and before, but with C++11 and later it is defined by standard (see `ISO14882:2011(e)`), and this code anyway targets C++17 so we're safe here.
The pull request has been merged as d680c02d03.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b patch-1-negative-minimum-value master
git pull origin patch-1-negative-minimum-value

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff patch-1-negative-minimum-value
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: clyne/constexpr-to-string#1
Loading…
There is no content yet.