There is the following piece of code
#include <iostream>
#include <type_traits>
thread_local std::aligned_storage_t<1024> data;
int main() {
std::cout << sizeof(data) << std::endl;
uint8_t * d = new (&data) uint8_t[1024];
d[1025] = '6';
std::cout << d[1025] << std::endl;
}
Sanitiser does not detect buffer overflow
Code sample https://godbolt.org/z/r34f9jexj
std::vectorin ASAN:std::vectorwill often allocate more memory than immediately needed to store the data (see.capacity()), and ASAN has code in there to still figure out that the read/write was out of bounds of the vector. My guess is that ASAN doesn't yet have special handling code foraligned_storage_t, which is why it's likely it doesn't find the error in your case.std::vectorneeds manual instrumentation only because you want to catch out-of-bounds accesses that are not outside the capacity (which isn't inherenrly illegal from ASAN's point of view).undefinedcatches it godbolt.org/z/TTrW1oYK3