Skip to content

Commit 22ec823

Browse files
jacobsacdunn2001
authored andcommitted
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 ffea45b commit 22ec823

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/test_lib_json/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
12151215
JSONTEST_ASSERT_EQUAL(-2147483648.5, val.asDouble());
12161216
JSONTEST_ASSERT_EQUAL(float(-2147483648.5), val.asFloat());
12171217
#ifdef JSON_HAS_INT64
1218-
JSONTEST_ASSERT_EQUAL(-Json::Int64(1) << 31, val.asLargestInt());
1218+
JSONTEST_ASSERT_EQUAL(-(Json::Int64(1) << 31), val.asLargestInt());
12191219
#endif
12201220
JSONTEST_ASSERT_EQUAL(true, val.asBool());
12211221
JSONTEST_ASSERT_EQUAL("-2147483648.5",

0 commit comments

Comments
 (0)