public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl,  at gimplify.c:2848
@ 2021-08-24 22:27 vlovich at gmail dot com
  2021-08-24 22:29 ` [Bug c++/102051] " vlovich at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vlovich at gmail dot com @ 2021-08-24 22:27 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
@ 2021-08-24 22:29 ` vlovich at gmail dot com
  2021-09-30 20:35 ` iains at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vlovich at gmail dot com @ 2021-08-24 22:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Vitali <vlovich at gmail dot com> ---
Tested via godbolt on 11 & 12.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: iains at gcc dot gnu.org @ 2021-09-30 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iains at gcc dot gnu.org

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
the preprocessed file compiles for me using current gcc-10, 11 and master -
could you provide a little more info? (does it still fail for your case?)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: iains at gcc dot gnu.org @ 2021-12-17 17:58 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-12-17
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: harris.hancock at gmail dot com @ 2023-07-21 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

Harris Hancock <harris.hancock at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harris.hancock at gmail dot com

--- Comment #3 from Harris Hancock <harris.hancock at gmail dot com> ---
I have observed this bug, too, while trying to compile Cap'n Proto with
coroutine support using GCC 10, 11, and 12.

Like Iain, the preprocessed file which Vitali uploaded compiles for me, at
least on various versions of x86-64 gcc available in Compiler Explorer.

However, Vitali's reduced example, available in the first Compiler Explorer
link he posted (https://godbolt.org/z/M5nfEPMKj) readily reproduces the ICE,
both in Compiler Explorer on gcc trunk and also locally for me using GCC 12
distributed by Ubuntu Jammy (g++-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0),
using `g++-12 -o the-file.o -c the-file.i -std=c++20`.

The ICE disappears if we modify the following line

  ~Own() noexcept(false);


to


  ~Own() noexcept(true);

So, this appears to be a coroutine bug related to noexcept(false) destructors,
similar to Bug 95822.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: harris.hancock at gmail dot com @ 2023-07-21 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Harris Hancock <harris.hancock at gmail dot com> ---
Created attachment 55597
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55597&action=edit
Reduced example which reproduces the ICE

I'm attaching the reduced example from Vitali's first Compiler Explorer link:
https://godbolt.org/z/M5nfEPMKj

Compile with:

  g++ -o bug-102051-reduced-example.o -c bug-102051-reduced-example.cpp
-std=c++20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: vaci at vaci dot org @ 2024-01-19 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

Vaci <vaci at vaci dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vaci at vaci dot org

--- Comment #5 from Vaci <vaci at vaci dot org> ---
Created attachment 57158
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57158&action=edit
Further reduced example that reproduces the ICE

The attached minimal code example also results in an internal_compiler error on
X64_64 gcc 13.2, as per godbolt:

https://godbolt.org/z/jEq8fvzr3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848
  2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
                   ` (5 preceding siblings ...)
  2024-01-19 11:41 ` vaci at vaci dot org
@ 2024-01-25 19:23 ` ppalka at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-25 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed with trunk/13.2/12.3/11.4 on the comment #5 testcase.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-25 19:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 22:27 [Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848 vlovich at gmail dot com
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

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).