https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115361
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- Giving a -Wdangling-ref warning for f7 and f9 is correct, but that warning is just based on simple heuristics in the front end. The -Wunitialized warning comes from the middle end and correctly detects a read of a variable outside its lifetime. That's a real bug, but the fact that it could be worded better is a separate issue from "-Wdangling-ref has too many false positives".