How to detect Out-of-Bounds Access within Placement New Boundaries in C++?
#include <iostream> struct mix { int64_t x[10]; }; int main() { int64_t* p = new int64_t[100]; mix* px = new (p) mix; mix* py = new (p + 10) mix; px->x[12] = 104; std::cout << py->x[2] << std::endl; delete[] p; } In this code, px and py are created using placement new within the same […]
How to detect Out-of-Bounds Access within Placement New Boundaries in C++?
#include <iostream> struct mix { int64_t x[10]; }; int main() { int64_t* p = new int64_t[100]; mix* px = new (p) mix; mix* py = new (p + 10) mix; px->x[12] = 104; std::cout << py->x[2] << std::endl; delete[] p; } In this code, px and py are created using placement new within the same […]