https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96311
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:aa3e2a211933efaeb6ecd0a69f196606b8a40b43 commit r9-10165-gaa3e2a211933efaeb6ecd0a69f196606b8a40b43 Author: Jason Merrill <ja...@redhat.com> Date: Mon Apr 5 16:22:51 2021 -0400 c++: -Wunused, constant, and generic lambda [PR96311] We never called mark_use for a return value in a function with dependent return type. In that situation we don't know if the use is as an rvalue or lvalue, but we can use mark_exp_read instead. gcc/cp/ChangeLog: PR c++/96311 * typeck.c (check_return_expr): Call mark_exp_read in dependent case. gcc/testsuite/ChangeLog: PR c++/96311 * g++.dg/cpp1y/lambda-generic-Wunused.C: New test.