Skip to content

Commit d68984e

Browse files
committed
add a pragma...
1 parent 959d8b0 commit d68984e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/protozero/varint.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ namespace detail {
3737
uint64_t val = 0;
3838

3939
if (iend - p >= max_varint_length) { // fast path
40-
__builtin_assume(iend - p >= max_varint_length);
4140
do {
41+
// GCC 12 has trouble understanding that we're not actually taking this branch for short buffers.
42+
#pragma GCC diagnostic push
43+
#pragma GCC diagnostic ignored "-Warray-bounds"
44+
#endif
4245
int64_t b = *p++;
4346
val = ((static_cast<uint64_t>(b) & 0x7fU) ); if (b >= 0) { break; }
4447
b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 7U); if (b >= 0) { break; }
@@ -50,6 +53,7 @@ namespace detail {
5053
b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 49U); if (b >= 0) { break; }
5154
b = *p++; val |= ((static_cast<uint64_t>(b) & 0x7fU) << 56U); if (b >= 0) { break; }
5255
b = *p++; val |= ((static_cast<uint64_t>(b) & 0x01U) << 63U); if (b >= 0) { break; }
56+
#pragma GCC diagnostic pop
5357
throw varint_too_long_exception{};
5458
} while (false);
5559
} else {

0 commit comments

Comments
 (0)