Nathan Sidwell wrote:
hi,
this patch fixes 20186 a recent c++ template regression. We can't
fold non-dependent expressions that contain something dependent. This
can happen with casts from a dependent type to a non-dependent type.
We abuse tsubst_copy to do the folding, and it goes horribly wrong.
This is really another case where we should mark such exprs as we build
them up ...
+ int i = static_cast<int>(t);
Why doesn't value_dependent_expression_p return true for that? It looks
like it should, as "t" has dependent type, and we have this code:
/* These expressions are value-dependent if the type to which the
cast occurs is dependent or the expression being casted is
value-dependent. */
if (TREE_CODE (expression) == DYNAMIC_CAST_EXPR
|| TREE_CODE (expression) == STATIC_CAST_EXPR
|| TREE_CODE (expression) == CONST_CAST_EXPR
|| TREE_CODE (expression) == REINTERPRET_CAST_EXPR
|| TREE_CODE (expression) == CAST_EXPR)
{
tree type = TREE_TYPE (expression);
if (dependent_type_p (type))
return true;