Skip to content
Snippets Groups Projects
Commit 59946a4c authored by Patrick Palka's avatar Patrick Palka
Browse files

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.
parent 682d401a
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment