Commit 9be79676 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Fix possible UB in constexpr_strcmp

Summary: [Folly] Fix possible UB in `constexpr_strcmp` since signed arithmetic wraparound is undefined.

Differential Revision: D23435902

fbshipit-source-id: f71103f58f9a1a69dbc7fa462703605d1fc78348
parent 2948741d
......@@ -44,7 +44,7 @@ constexpr int constexpr_strcmp_fallback(const Char* s1, const Char* s2) {
while (*s1 && *s1 == *s2) {
++s1, ++s2;
}
return static_cast<int>(*s1 - *s2);
return int(*s2 < *s1) - int(*s1 < *s2);
}
} // namespace detail
......
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