Fix undefined behaviour in 128-bit integer-to-string conversion
authorMarcus Holland-Moritz <mhx@fb.com>
Fri, 24 Jun 2016 02:34:48 +0000 (19:34 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Fri, 24 Jun 2016 02:38:38 +0000 (19:38 -0700)
commitf97b156e966cb964cc33dd44db480a8c56d004f0
treed11421fe5b5e03eb7ebdd71c3ee6b906ee8658c5
parent05a4c2214c0fe151e03e642e3892844f57fa3922
Fix undefined behaviour in 128-bit integer-to-string conversion

Summary:
The code to convert signed 128-bit integer values to strings would trigger
undefined behaviour when trying to convert the most negative possible value,
as exposed by the new test cases.

The fix is to negate the corresponding unsigned value (just like it's already
done for the 64-bit code).

This change doesn't have any performance impact.

Reviewed By: yfeldblum

Differential Revision: D3455817

fbshipit-source-id: 83782992324f443789760a0e61cd9b889faaf317
folly/Conv.h
folly/test/ConvTest.cpp