https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127950
--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
To expand on that the lifetime of the object starts when call with new and ends
with delete.
Basically this code is very much undefined.
f->next = 0; // ignored by g++ -O
delete f;
The lifetime of the object that is at f has ended so the store to f->next is
considered dead as it would be undefined to read from it again.
https://en.cppreference.com/cpp/language/lifetime is a good place to start to
read about lifetimes and why the code you provided is undefined.