The error was in the code of the test itself: the special case of zero
wasn't handled correctrly by the function that prepares input data for
the test. As a result, zero-length input string was passed to the test,
which is unexpected: the tested function is an "unsafe" one (as the
name suggests) and is meant to be used on an already validated input.
// no terminating null as we don't need it
static char * u64_to_s_fastest_ever (uint64_t u, char * s)
{
- while (u > 0)
- {
- const uint64_t d = u % 10 + '0';
- *--s = static_cast<char> (d);
- u /= 10;
+ if (u == 0) {
+ *--s = '0';
+ }
+ else {
+ while (u > 0) {
+ const uint64_t d = u % 10 + '0';
+ *--s = static_cast<char> (d);
+ u /= 10;
+ }
}
return s;
}