Fix compilation error with -Werror=array-bounds

This error happened only with O2 or O3 in my tests.
Casting to uintptr_t and back seems to quiet the compiler.
This commit is contained in:
Jacques Lucke 2020-09-01 11:11:12 +02:00
parent 1449ae042e
commit 114150e80c
1 changed files with 2 additions and 1 deletions

View File

@ -237,7 +237,8 @@ TEST(span, ContainsPtr)
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 1));
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 2));
EXPECT_FALSE(a_span.contains_ptr(&a[0] + 3));
EXPECT_FALSE(a_span.contains_ptr(&a[0] - 1));
int *ptr_before = reinterpret_cast<int *>(reinterpret_cast<uintptr_t>(a.data()) - 1);
EXPECT_FALSE(a_span.contains_ptr(ptr_before));
EXPECT_FALSE(a_span.contains_ptr(&other));
}