binary_reader.hpp:650: (style) Unsigned expression 'mant' can't be negative so it is unnecessary to test it
910a7d2b87/checks (step):5:84
Signed-off-by: Xav83 <x.jouvenot@gmail.com>
For some gcc version (Ubuntu 5.5.0-12ubuntu1~16.04) the existing code
crashes when the minimum value of int64_t is outputted.
Resurrect the code from before 546e2cbf (🚨 fixed some warnings,
2019-03-13) but delegate the sign removal so that the compilers don't
complain about taking the negative value of an unsigned value.
In addition we also rewrite the expression so that we first increment
and then negate.
The definition of remove_sign(number_unsigned_t) is never called as
unsigned values are never negative.
Clang UBSAN currently complains that the char * to input_buffer_adapter
is a nullptr.
Turns out it is actually required to accept nullptr, see for example
line 415 in input_adapters.hpp
...
// the address of first cannot be used: use nullptr
ia = std::make_shared<input_buffer_adapter>(nullptr, len);
....
Therefore we have to handle it gracefully here. We now also ignore the
length parameter l if b is a nullptr.
While in our case, only the string case was affected, to be safe and allow the library to work with other unforeseen cases, all of the cases have been wrapped with parentheses.
Thank you @DyXel and @edo9300