https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110122
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:59946a4c0c97c842ac5a34de5b1aadb73b738809 commit r14-1698-g59946a4c0c97c842ac5a34de5b1aadb73b738809 Author: Patrick Palka <ppa...@redhat.com> Date: Sun Jun 11 11:27:10 2023 -0400 c++: unsynthesized defaulted constexpr fn [PR110122] In this other testcase from PR110122, during regeneration of the generic lambda with V=Bar{}, substitution followed by coerce_template_parms for A<V>'s template argument naturally yields a copy of V in terms of Bar's (implicitly) defaulted copy constructor. This however happens inside a template context so although we introduced a use of the copy constructor, mark_used didn't actually synthesize it, which causes subsequent constant evaluation of the template argument to fail with: nontype-class59.C: In instantiation of âvoid f() [with Bar V = Bar{Foo()}]â: nontype-class59.C:22:11: required from here nontype-class59.C:18:18: error: âconstexpr Bar::Bar(const Bar&)â used before its definition We already make sure to instantiate templated constexpr functions needed for constant evaluation (as per P0859R0). So this patch fixes this by making us synthesize defaulted constexpr functions needed for constant evaluation as well. PR c++/110122 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Synthesize defaulted functions needed for constant evaluation. (instantiate_cx_fn_r): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class59.C: New test.