https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165
--- Comment #3 from Romain Geissler <romain.geissler at amadeus dot com> --- In my real life case B was std::string and used a "string literal" at call site, and I guess using the implicit conversion from const char[] to std::string is something that might happen in many call sites in big code bases. Is it expected that -Wdangling-reference doesn't take into account the definition of f ? The problem of dangling reference in general needs function definitions to be effective, otherwise I fear there might be quite some false positives.