Fix conversion from bool to floating point value
authorMarcus Holland-Moritz <mhx@fb.com>
Fri, 24 Jun 2016 00:22:33 +0000 (17:22 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Fri, 24 Jun 2016 00:23:30 +0000 (17:23 -0700)
commit29c7ba51cdf0db9c5809a43ff6eab7e14bf21b6f
tree5661009ccb4de15c01bb3e139a31190ae6cbac4e
parent1186ac53ae1a7a169446c24c6f5d4fa1a06daa4d
Fix conversion from bool to floating point value

Summary:
Due to the definition of how floating point values convert to boolean,
the check for undefined behaviour wouldn't work correctly. The result
of (1 - 0.9999999999999999) would yield 0 when converted to an integer,
but yields true (1) when converted to a boolean.

As all floating point values can thus be converted to boolean without
triggering undefined behaviour, this change overloads checkConversion()
appropriately

Reviewed By: yfeldblum

Differential Revision: D3477368

fbshipit-source-id: 5b2aeb6194629cf3a6195529aac2362c0d35799c
folly/Conv.h
folly/test/ConvTest.cpp