please review this. i'll try to figure out tests for everything, though it seems annoying :)
https://www.netbsd.org/~mrg/gcc12-use-after-free.diff it should handle all the open use-after-free problems. .mrg. ps: you'll notice no new headers needed for ptrdiff_t usage ;)