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.