This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix 20186


Mark Mitchell wrote:
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;
This is checking whether the target type is dependent, NOT the
source type.



So, I'm perplexed as to how your patch could acutally change anything. (Insert comments about empiricists vs. theoreticians here. :-))




--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]