https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115987
--- Comment #23 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:34d947134403e7482ba4f153d8faabee0bc4933e commit r15-2727-g34d947134403e7482ba4f153d8faabee0bc4933e Author: Marek Polacek <pola...@redhat.com> Date: Wed Jul 31 17:33:55 2024 -0400 c++: fix -Wdangling-reference false positive [PR115987] This fixes another false positive. When a function is taking a temporary of scalar type that couldn't be bound to the return type of the function, don't warn, such a program would be ill-formed. Thanks to Jonathan for reporting the problem. PR c++/115987 gcc/cp/ChangeLog: * call.cc (do_warn_dangling_reference): Don't consider a temporary with a scalar type that cannot bind to the return type. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-no-dangling6.C: Adjust. * g++.dg/ext/attr-no-dangling7.C: Likewise. * g++.dg/warn/Wdangling-reference22.C: New test.