Skip to content

Commit 258452d

Browse files
committed
speculative fix for appeasing GCC's bounds checker
1 parent 2bf170a commit 258452d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

.github/workflows/clang-tidy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
apt-get install -yq \
3434
clang-${{ matrix.clang }} \
3535
clang-tidy-${{ matrix.clang }} \
36+
libstdc++-dev \
3637
cmake \
3738
libprotobuf-dev \
3839
make \

include/protozero/varint.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ namespace detail {
3232

3333
// from https://github.com/facebook/folly/blob/master/folly/Varint.h
3434
inline uint64_t decode_varint_impl(const char** data, const char* end) {
35-
const auto* begin = reinterpret_cast<const int8_t*>(*data);
36-
const auto* iend = reinterpret_cast<const int8_t*>(end);
37-
const int8_t* p = begin;
35+
const int8_t* p = reinterpret_cast<const int8_t*>(*data);
36+
const int8_t* const iend = reinterpret_cast<const int8_t*>(end);
3837
uint64_t val = 0;
3938

40-
if (iend - begin >= max_varint_length) { // fast path
41-
assert(iend - p >= max_varint_length); // help Clang analyzer
39+
if (iend - p >= max_varint_length) { // fast path
4240
do {
4341
int64_t b = *p++;
4442
val = ((static_cast<uint64_t>(b) & 0x7fU) ); if (b >= 0) { break; }

0 commit comments

Comments
 (0)