Fixed potential bug with -MINIMUM_VALUE #1

Merged
EnilPajic merged 3 commits from patch-1-negative-minimum-value into master 4 years ago

3 Commits (master)

Author SHA1 Message Date
Clyne 6e7939000f
Change base from unsigned to signed 4 years ago
Clyne a7dd0243fe
Merge branch 'master' into patch-1-negative-minimum-value 4 years ago
EnilPajic 5baf5d3dae
Fixed potential bug with -MINIMUM_VALUE
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.
4 years ago