https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109774
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:22741a09a8cbf8a360e99e530b016233dd705ce4 commit r13-7337-g22741a09a8cbf8a360e99e530b016233dd705ce4 Author: Marek Polacek <pola...@redhat.com> Date: Tue May 16 14:12:06 2023 -0400 c++: -Wdangling-reference not suppressed in template [PR109774] In check_return_expr, we suppress the -Wdangling-reference warning when we're sure it would be a false positive. It wasn't working in a template, though, because the suppress_warning call was never reached. PR c++/109774 gcc/cp/ChangeLog: * typeck.cc (check_return_expr): In a template, return only after suppressing -Wdangling-reference. gcc/testsuite/ChangeLog: * g++.dg/warn/Wdangling-reference13.C: New test. (cherry picked from commit f25d2de17663a0132f9fe090dee39d3b1132067b)