https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82309
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Sergey Markelov from comment #6) > Unfortunately -fsanitize=undefined does not catch this. Thank you for your > help. -fsanitize=address catchs it, specifically the use-after-return sanitizer, but only since GCC 7.