https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119251
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #7) > GCC already has Wdangling-pointer which is done at optimization time too so > I suspect it should catch most of these. Though it should be improved for > handling clobbers if not already done. We do emit clobbers for those already. Plus there are sanitizers, one can easily diagnose uses after scope that way.