On 03/17/2014 05:38 AM, Paolo Carlini wrote:
noticed this issue, which looks simple to fix. The ICE happens in
cxx_eval_constant_expression, because it cannot handle a CAST_EXPR (or
any othe *_CAST, for that matter). In fact check_narrowing calls
maybe_constant_value, and, because we are in a template, the latter
faces the unfolded CAST_EXPR. Thus it seems easy to just use
fold_non_dependent_expr_sfinae. Tested x86_64-linux.

OK.

PS: looking forward, I'm wondering if some semantics/typeck functions
shouldn't try harder before building a tree node and returning, eg,
instead of just checking processing_template_decl, actually checking if
type and expr are dependent? Does this kind of audit make sense for next
Stage 1?

In general adding fold_non_dependent_expr where it's needed is the right answer, because normal operation creates tree patterns that tsubst doesn't understand how to deal with.

I suppose it might work to always fully build non-instantiation-dependent expressions, wrap them in NON_DEPENDENT_EXPR, and then unshare its operand at instantiation time. But that would be a significant change with unclear benefit.

Jason

Reply via email to