https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987
--- Comment #2 from Dan Urosu <durosu at yahoo dot com> --- Hi Andrew, I cannot use "#pragma GCC diagnostic ignored" because we have thousands of call sites where we plan to use this kind of code. And we don't want to disable globally this warning either. Would "no_dangling (with GCC 14+) " disable globally this check as well? Thanks,Dan On Thursday, July 18, 2024 at 11:53:32 AM EDT, pinskia at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org> wrote: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- You either need to use gnu::no_dangling (with GCC 14+) or #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdangling-reference" ... #pragma GCC diagnostic pop As mentioned in PR 109642. This is not exactly a false positive since GCC does not look further into the functions to see if they return the reference or not. *** This bug has been marked as a duplicate of bug 109642 ***