public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vlovich at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl,  at gimplify.c:2848
Date: Tue, 24 Aug 2021 22:27:57 +0000	[thread overview]
Message-ID: <bug-102051-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 102051
           Summary: [coroutines] ICE in gimplify_var_or_parm_decl, at
                    gimplify.c:2848
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vlovich at gmail dot com
  Target Milestone: ---

Created attachment 51353
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51353&action=edit
The preprocessed file that causes the ICE

We're adding co-routine support to KJ futures
(https://github.com/capnproto/capnproto/pull/1104). I tried enabling coroutines
on G++ by adjusting async-prelude.h:
<code>
-#if __cpp_coroutines && __has_include(<experimental/coroutine>)
+#if __cpp_impl_coroutine && __has_include(<coroutine>)
+// Standardized coroutines detected.
+#include <coroutine>
+#define KJ_HAS_COROUTINE 1
+#define KJ_COROUTINE_STD_NAMESPACE std
+#elif __cpp_coroutines && __has_include(<experimental/coroutine>)
</code>

This results in an ICE in our test case:
<code>
# g++ -std=c++20 -fcoroutines
./c++/src/kj/CMakeFiles/kj-heavy-tests.dir/async-coroutine-test.c++.ii
c++/src/kj/async-coroutine-test.c++: In function ‘kj::Promise<const char*>
kj::{anonymous}::identity(const char*)’:
c++/src/kj/async-coroutine-test.c++:40:1: internal compiler error: in
gimplify_var_or_parm_decl, at gimplify.c:2840
   40 | }
      | ^
0x1797368 internal_error(char const*, ...)
        ???:0
0x67f8f9 fancy_abort(char const*, int, char const*)
        ???:0
0xab710f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab7130 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab7a2c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab81dd gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab7417 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab86ea gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab723e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xab86ea gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xabac7a gimplify_body(tree_node*, bool)
        ???:0
0xabb022 gimplify_function_tree(tree_node*)
        ???:0
0x949a87 cgraph_node::analyze()
        ???:0
0x94cc2d symbol_table::finalize_compilation_unit()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
</code>

I reduced the test case using cvise: https://godbolt.org/z/M5nfEPMKj. This code
works fine against clang's coroutines TS but interestingly clang complains the
reduced test case doesn't compile (https://godbolt.org/z/KjcW94oKM) so maybe
there's just some subtle incompatibility between standard coroutines & the TS
version implemented in clang?

I've attached the full preprocessed file that caused the ICE. Interestingly if
I build against libc++ the ICE doesn't appear so I suspect this may be some
kind of bug in the frontend triggered by some subtlety in the implementation in
libstdc++ OR it's a compilation bug on our end that happens to trigger an ICE.
I don't know coroutines well enough to say.

             reply	other threads:[~2021-08-24 22:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 22:27 vlovich at gmail dot com [this message]
2021-08-24 22:29 ` [Bug c++/102051] " vlovich at gmail dot com
2021-09-30 20:35 ` iains at gcc dot gnu.org
2021-12-17 17:58 ` iains at gcc dot gnu.org
2023-07-21 21:04 ` harris.hancock at gmail dot com
2023-07-21 21:12 ` harris.hancock at gmail dot com
2024-01-19 11:41 ` vaci at vaci dot org
2024-01-25 19:23 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102051-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).