https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111159
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I think so too; I'm afraid there's no heuristic I could implement. You can disable the warning for this class using: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdangling-reference" struct A { int * i; int & b() { return *i; } }; #pragma GCC diagnostic pop *** This bug has been marked as a duplicate of bug 109642 ***