Hard
An overflow guard written in pointer arithmetic
Compiled with -O2, is this a reliable way to detect that buf + len wrapped around the end of the address space?
main.cpp
#include <cstddef>
bool bufferFits(char* buf, size_t len) {
char* end = buf + len;
// meant to catch pointer-arithmetic overflow
if (end < buf) {
return false;
}
return true;
}1 of 44 in Compilers