On Wed, Feb 28, 2018 at 09:11:24AM -0300, Alexandre Oliva wrote:
> Evaluation of constant expressions, such as those passed to
> static_assert, ICEd when encountering IMPLICIT_CONV_EXPRs.
> 
> Handle them like CONVERT_EXPR and NOP_EXPR.
> 
> Regstrapped on x86_64- and i686-linux-gnu.  Ok to install?
> 
> for  gcc/cp/ChangeLog
> 
>       PR c++/84596
>       * constexpr.c (cxx_eval_constant_expression): Handle
>       IMPLICIT_CONV_EXPR.
> 
> for  gcc/testsuite/ChangeLog
> 
>       PR c++/84596
>       * g++.dg/cpp0x/pr84596.C: New.
> ---
>  gcc/cp/constexpr.c                   |    1 +
>  gcc/testsuite/g++.dg/cpp0x/pr84596.C |    7 +++++++
>  2 files changed, 8 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr84596.C
> 
> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
> index 4bbdbf434877..d38e2d83ae8c 100644
> --- a/gcc/cp/constexpr.c
> +++ b/gcc/cp/constexpr.c
> @@ -4549,6 +4549,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
> tree t,
>                                      non_constant_p, overflow_p);
>        break;
>  
> +    case IMPLICIT_CONV_EXPR:
>      case CONVERT_EXPR:
>      case VIEW_CONVERT_EXPR:
>      case NOP_EXPR:

I don't think it's correct to handle template codes here; they shouldn't
have gotten to cxx_eval_constant_expression in the first place.  Usually
they're substituted in instantiate_non_dependent_expr_internal e.g. via
calling fold_non_dependent_expr.  So I guess we need to find out how
IMPLICIT_CONV_EXPR has gotten there.

        Marek

Reply via email to