Commit 043bf35f authored by Jason Meisel's avatar Jason Meisel Committed by Facebook Github Bot

Fix Conv.cpp unary minus operator applied to unsigned type

Summary: Cast from unsigned to signed *before* negating. The resulting assembly code is the same, but there's no warning.

Reviewed By: yfeldblum, jdonald

Differential Revision: D19588115

fbshipit-source-id: d0d61ab0543211e2399f42a86a7a7a2366679d37
parent 16b3011a
......@@ -489,7 +489,14 @@ class SignedValueHandler<T, true> {
Expected<T, ConversionCode> finalize(U value) {
T rv;
if (negative_) {
FOLLY_PUSH_WARNING
FOLLY_MSVC_DISABLE_WARNING(4146)
// unary minus operator applied to unsigned type, result still unsigned
rv = T(-value);
FOLLY_POP_WARNING
if (UNLIKELY(rv > 0)) {
return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment