[Bug c++/123613] [reflection] internal compiler error: tree check: expected record_type or union_type or qual_union_type, have template_type_parm in lookup_base, at cp/search.cc:265
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 26 13:39:05 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123613
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:007969e7765343619925f726ec1f340895c192b3
commit r16-8292-g007969e7765343619925f726ec1f340895c192b3
Author: Marek Polacek <polacek@redhat.com>
Date: Thu Mar 19 13:10:38 2026 -0400
c++/reflection: ICE with substitute and undeduced auto [PR123613]
In substitute7.C we have
template <typename T, auto ... Vs>
constexpr auto construct_from = T{Vs...}; // #1
struct Inner {};
struct Outer { Inner m; };
constexpr auto r = substitute(^^construct_from,
{ ^^Outer, ^^construct_from<Inner> });
which crashes because the auto in #1 hadn't been deduced when we
called eval_can_substitute -> lookup_template_variable when processing
the substitute call. We can call mark_used to resolve this, because
it has:
if (undeduced_auto_decl (decl))
maybe_instantiate_decl (decl);
and to make the json-parser.C test work, we have to do something
similar in eval_substitute, otherwise we crash due to another
undeduced auto.
PR c++/123613
gcc/cp/ChangeLog:
* reflect.cc (get_reflection): Call mark_used.
(eval_can_substitute): Don't resolve_nondeduced_context here.
(eval_substitute): Call lookup_and_finish_template_variable instead
of lookup_template_variable and finish_template_variable.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/json-parser.C: New test.
* g++.dg/reflect/substitute7.C: New test.
* g++.dg/reflect/test.json: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list