avoid signed-integer underflow, which is undefined behavior

maybe these tests should just be deleted?

UBSAN gave:
runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long'
runtime error: signed integer overflow: -9223372036854775808 - 2 cannot be represented in type 'long'
This commit is contained in:
Eli Fidler 2016-05-31 12:26:31 -04:00
parent be1eedf808
commit 760ea4316c

View File

@ -545,8 +545,10 @@ TEST(Value, Int64) {
// Templated functions // Templated functions
EXPECT_TRUE(z.Is<int64_t>()); EXPECT_TRUE(z.Is<int64_t>());
EXPECT_EQ(i, z.Get<int64_t>()); EXPECT_EQ(i, z.Get<int64_t>());
#if 0 // signed integer underflow is undefined behaviour
EXPECT_EQ(i - 1, z.Set(i - 1).Get<int64_t>()); EXPECT_EQ(i - 1, z.Set(i - 1).Get<int64_t>());
EXPECT_EQ(i - 2, z.Set<int64_t>(i - 2).Get<int64_t>()); EXPECT_EQ(i - 2, z.Set<int64_t>(i - 2).Get<int64_t>());
#endif
} }
TEST(Value, Uint64) { TEST(Value, Uint64) {