https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103319

            Bug ID: 103319
           Summary: [coroutines] ICE in is_this_parameter, at
                    cp/semantics.c:10672
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: a...@cloudius-systems.com
  Target Milestone: ---

Possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102489

A very large test case gives me this:

distcc[3605276] ERROR: compile /home/avi/scylla/db/commitlog/commitlog.cc on
localhost failed
/home/avi/scylla/db/commitlog/commitlog.cc: In function ‘void
db::commitlog::segment::cycle(bool,
bool)::<lambda()>::operator()(db::commitlog::segment::cycle(bool,
bool)::<lambda()>::_ZZN2db9commitlog7segment5cycleEbbENKUlvE_clEv.frame*)’:
/home/avi/scylla/db/commitlog/commitlog.cc:901:9: internal compiler error: in
is_this_parameter, at cp/semantics.c:10672
  901 |         }, [&]() -> future<> {


It is accepted by clang.

gcc 12 accepts the code, and gcc 11 with this patch backported:

commit daa9c6b015a33fa98af0ee7cd6919120248ab5f9 (tag: is_this_parameter)
Author: Jason Merrill <ja...@redhat.com>
Date:   Sat Nov 13 17:16:46 2021 -0500

    c++: is_this_parameter and coroutines proxies

    Compiling coroutines/pr95736.C with the implicit constexpr patch broke
    because is_this_parameter didn't recognize the coroutines proxy for 'this'.

    gcc/cp/ChangeLog:

            * semantics.c (is_this_parameter): Check DECL_HAS_VALUE_EXPR_P
            instead of is_capture_proxy.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 60e0982cc48..15404426bce 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -11380,11 +11380,12 @@ float_const_decimal64_p (void)
 bool
 is_this_parameter (tree t)
 {
   if (!DECL_P (t) || DECL_NAME (t) != this_identifier)
     return false;
-  gcc_assert (TREE_CODE (t) == PARM_DECL || is_capture_proxy (t)
+  gcc_assert (TREE_CODE (t) == PARM_DECL
+             || (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
              || (cp_binding_oracle && TREE_CODE (t) == VAR_DECL));
   return true;
 }

 /* Insert the deduced return type for an auto function.  */



Also works. Requesting this backport for gcc 11 (I don't know if this is a
regression or not since I'm attempting to migrate from clang).

I don't have a reduced test case. I can try to reduce it, but perhaps knowledge
of the fix will make coming up with a small test case simple.

Reply via email to