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: C++ PATCH for c++/84925, ICE in enclosing_instantiation_of


OK.

On Mon, Mar 19, 2018 at 7:55 AM, Marek Polacek <polacek@redhat.com> wrote:
> Seems like with this testcase we end up in a scenario where, when counting the
> lambda count in enclosing_instantiation_of, we arrive at decl_function_context
> being null, so checking DECL_TEMPLATE_INFO then crashes.  It appears that just
> the following does the right thing, but I'm not too sure about this function.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-03-19  Marek Polacek  <polacek@redhat.com>
>
>         PR c++/84925
>         * pt.c (enclosing_instantiation_of): Check if fn is null.
>
>         * g++.dg/cpp1z/lambda-__func__.C: New test.
>
> diff --git gcc/cp/pt.c gcc/cp/pt.c
> index 745c9acd6ee..066cb627a70 100644
> --- gcc/cp/pt.c
> +++ gcc/cp/pt.c
> @@ -12898,7 +12898,7 @@ enclosing_instantiation_of (tree otctx)
>        for (; flambda_count < lambda_count && fn && LAMBDA_FUNCTION_P (fn);
>            fn = decl_function_context (fn))
>         ++flambda_count;
> -      if (DECL_TEMPLATE_INFO (fn)
> +      if ((fn && DECL_TEMPLATE_INFO (fn))
>           ? most_general_template (fn) != most_general_template (tctx)
>           : fn != tctx)
>         continue;
> diff --git gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C
> index e69de29bb2d..d5d1c1cb7b6 100644
> --- gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C
> +++ gcc/testsuite/g++.dg/cpp1z/lambda-__func__.C
> @@ -0,0 +1,13 @@
> +// PR c++/84925
> +// { dg-options "-std=c++17" }
> +
> +template <typename>
> +struct A {
> +  static const int value = 0;
> +  static auto constexpr fn = [] { return __func__; };
> +};
> +
> +template <typename type>
> +int x = A<type>::value;
> +
> +auto s = x<int>;
>
>         Marek


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