https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
--- Comment #20 from Rolf Eike Beer <e...@sf-mail.de> --- I'm running this rev: g++-13 (Gentoo 13.0.1.9999 p, commit 27495bc8fe028d4a68e97ad12b52231772e48dcf) 13.0.1 20230308 (experimental) And I still get a warning for this testcase: // $ cat ref.cpp #include <string> const std::string &trigger(const std::string &server); int verifyDevXml() { const auto &str = trigger(""); if (str.empty()) return 1; return 0; } // $ g++-13 -Wdangling-reference -c -o ref.o ref.cpp ref.cpp: In function ?int verifyDevXml()?: ref.cpp:7:15: warning: possibly dangling reference to a temporary [-Wdangling-reference] 7 | const auto &str = trigger(""); | ^~~ ref.cpp:7:28: note: the temporary was destroyed at the end of the full expression ?trigger(std::__cxx11::basic_string<char>(((const char*)""), std::allocator<char>()))? 7 | const auto &str = trigger(""); | ~~~~~~~^~~~ The problem is to my understanding that this warns about the temporary constructed in the argument, i.e. it warns that the std::string() formed from "" could be bound here. Which could be true if the function does that, but in my case it is just used as a lookup for a map and not returned.