Fix UB in folly/experimental/Bits.h
authorTom Jackson <tjackson@fb.com>
Thu, 1 Jun 2017 15:33:55 +0000 (08:33 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 1 Jun 2017 15:38:08 +0000 (08:38 -0700)
commita1d62691af2d6c77deeba925cfd0e8172f1d106c
tree3758097aeb085767cfab5ab5719e40e4d8dad0dc
parentd53c91d0bc5108c14e9ab8c6726777dec2048843
Fix UB in folly/experimental/Bits.h

Summary:
Test output before the fix is applied:
```
folly/experimental/Bits.h:247:59: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
     #0 folly/experimental/Bits.h:247 folly::Bits<...>::set(int*, unsigned long, unsigned long, int)
     #1 folly/experimental/test/BitsTest.cpp:228 std::enable_if<...>::type (anonymous namespace)::testSet<...>(unsigned char*, unsigned long, unsigned long, int)
     #2 folly/experimental/test/BitsTest.cpp:263 Bits_Boundaries_Test::TestBody()
    #17 folly/experimental/test/BitsTest.cpp:381 main
```

Reviewed By: philippv

Differential Revision: D5160789

fbshipit-source-id: 43f1926d58f1a5c019d4f8794d10a7a80a5c4749
folly/experimental/Bits.h
folly/experimental/test/BitsTest.cpp