Skip to content

Commit cc2c15c

Browse files
committed
Remove undefined behavior from a left shift of a negative value.
Fixed by shifting a positive value, then negating the result. (Credit: Richard Trieu)
1 parent 912d550 commit cc2c15c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/test_lib_json/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
12121212
JSONTEST_ASSERT_EQUAL(-2147483648.5, val.asDouble());
12131213
JSONTEST_ASSERT_EQUAL(float(-2147483648.5), val.asFloat());
12141214
#ifdef JSON_HAS_INT64
1215-
JSONTEST_ASSERT_EQUAL(-Json::Int64(1) << 31, val.asLargestInt());
1215+
JSONTEST_ASSERT_EQUAL(-(Json::Int64(1) << 31), val.asLargestInt());
12161216
#endif
12171217
JSONTEST_ASSERT_EQUAL(true, val.asBool());
12181218
JSONTEST_ASSERT_EQUAL("-2147483648.5",

0 commit comments

Comments
 (0)