https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96311
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:b07dd9b0d0e501a0083da79e2bca17041c007ec8 commit r11-7995-gb07dd9b0d0e501a0083da79e2bca17041c007ec8 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.