Ниже приведен мой пример
Код: Выделить всё
#include
#include
#include
constexpr size_t N = 32;
class A {
public:
int x;
};
int main() {
char buf [sizeof(A)];
A *a = new (buf) A;
__sanitizer_annotate_contiguous_container(buf, buf + sizeof(A), buf, buf + sizeof(A));
a->~A();
a[sizeof(A) + 64].x = 4;
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79031504/c-use-container-annotation-wrapper-for-detect-memory-buffer-overflow-does-not[/url]