From: Marek Polacek Date: Wed, 28 Jan 2026 21:26:35 +0000 (-0500) Subject: c++/reflection: add assert to eval_type_trait X-Git-Tag: basepoints/gcc-17~1663 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec8ec2755f0bc387dddaa8920b1154455e0ee7fe;p=thirdparty%2Fgcc.git c++/reflection: add assert to eval_type_trait As discussed in . 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 --- diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 4174c2ef855..141294dd2b2 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; }