https://gcc.gnu.org/g:ec8ec2755f0bc387dddaa8920b1154455e0ee7fe
commit r16-7141-gec8ec2755f0bc387dddaa8920b1154455e0ee7fe Author: Marek Polacek <[email protected]> Date: Wed Jan 28 16:26:35 2026 -0500 c++/reflection: add assert to eval_type_trait As discussed in <https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>. Since we check eval_is_type in process_metafunction: if (eval_is_type (ht) != boolean_true_node) return throw_exception_nontype (loc, ctx, fun, non_constant_p, jump_target); finish_trait_expr should never return error_mark_node. We can ensure that it's so by adding an assert. gcc/cp/ChangeLog: * reflect.cc (eval_type_trait): Assert that finish_trait_expr didn't return error_mark_node. Reviewed-by: Jason Merrill <[email protected]> Diff: --- gcc/cp/reflect.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 4174c2ef8553..141294dd2b2c 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -3920,6 +3920,7 @@ static tree eval_type_trait (location_t loc, tree type1, tree type2, cp_trait_kind kind) { tree r = finish_trait_expr (loc, kind, type1, type2); + gcc_checking_assert (r != error_mark_node); STRIP_ANY_LOCATION_WRAPPER (r); return r; }
