https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112100
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jan Engelhardt from comment #0) > ==55843==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xsomething How would that even be possible? The terminating nul clearly has to be in allocated memory, because you are allowed to read it. So asan can't treat it as overflow. It's valid memory. Not only that, it's valid *writable* memory. You are allowed to store '\0' there. It would need a completely new category of "memory location that you can read and write to but nothing else". That's not an asan or ubsan check. > https://eel.is/c++draft/string.access specifies the modification of the NUL > char's position to values other than \0 is UB, so it should warn about this. There are hundreds of things the standard says are undefined that asan and ubsan can never detect. It's unreasonable to expect it IMHO.