https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105857
--- Comment #8 from andysem at mail dot ru --- I think, sanitizers won't detect it unless you build libstdc++ with them enabled. I would expect valgrind to detect it though. I think, Ubuntu builds libstdc++ with _FORTIFY_SOURCE enabled, which is why it checks for pointer validity and fails.