On Thu, Feb 19, 2026 at 03:10:14PM +0900, Jason Merrill wrote:
> > without tf_error return NULL_TREE. Similarly
>
> ...but the function comment says that we should return error_mark_node on
> failure when !tf_error.
Yeah, but the function itself is pretty random on when it returns NULL_TREE
or error_mark_node.
if (complain & tf_error)
error ("%qE is not a valid template argument for type %qT "
"because string literals can never be used in this context",
expr, type);
return NULL_TREE;
is common there.
And callers only care about it if complain & tf_error:
val = convert_nontype_argument (t, orig_arg, complain);
else
{
val = canonicalize_expr_argument (orig_arg, complain);
val = maybe_convert_nontype_argument (t, val, force_conv);
}
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
error_at (cp_expr_loc_or_input_loc (orig_arg),
"could not convert template argument %qE from %qT to %qT",
orig_arg, TREE_TYPE (orig_arg), t);
and
tree r = convert_nontype_argument (type, expr, complain);
if (r == NULL_TREE)
r = error_mark_node;
RETURN (r);
and
expr = convert_nontype_argument (type, expr, tf_none);
if (!expr)
return error_mark_node;
return expr;
So maybe we should just clarify the function comment.
Jakub