public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition.
@ 2020-12-30 16:18 dpsicilia at gmail dot com
  2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dpsicilia at gmail dot com @ 2020-12-30 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98480
           Summary: [coroutines] ICE on co_await in for-loop end
                    condition.
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dpsicilia at gmail dot com
  Target Milestone: ---

Quick Minimal reproducer: https://godbolt.org/z/Wrv54E

--------------------------------------------------------

Summary: when a co_await is placed in the end condition
of a for loop it causes gcc to ICE.  If I pull the
co_await out and store the result in a variable then the
issue goes away.

--------------------------------------------------------

Version of GCC: 10.2.0
System type: Linux x64
Command line: -std=c++20 -fcoroutines
Compiler output: ICE (see godbolt link; full stack trace below).

--------------------------------------------------------

// Standalone reproducer (same as godbolt link above).
#include <coroutine>

struct future {
  struct promise_type {
    void return_value(int) {}
    auto initial_suspend() { return std::suspend_never{}; }
    auto final_suspend() { return std::suspend_never{}; }
    void unhandled_exception() {}
    future get_return_object() { return {}; }
  };
  bool await_ready() { return true; }
  void await_suspend(std::coroutine_handle<>) {}
  int await_resume() { return 0; }
};

future co_foo() {
  for( int i = 0; i < co_await future{}; ++i );
  // ICE -------------^
  co_return 0;
}

--------------------------------------------------------

reproducer.cpp: In function ‘void
_Z6co_foov.actor(co_foo()::_Z6co_foov.frame*)’:
reproducer.cpp:17:3: internal compiler error: in fold_convert_loc, at
fold-const.c:2435
  285 |   for( int i = 0; i < co_await future{}; ++i )
      |   ^~~
0x5fd0ae fold_convert_loc(unsigned int, tree_node*, tree_node*)
        ../../gcc/fold-const.c:2435
0x9fae2a gimplify_cond_expr
        ../../gcc/gimplify.c:4149
0x9f2f1b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:13513
0x9f3705 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
0x9f3705 gimplify_statement_list
        ../../gcc/gimplify.c:1869
0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14000
0x9f64f9 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
0x9f64f9 gimplify_and_add(tree_node*, gimple**)
        ../../gcc/gimplify.c:486
0x9f64f9 gimplify_loop_expr
        ../../gcc/gimplify.c:1843
0x9f37b6 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:13761
0x9f3705 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
0x9f3705 gimplify_statement_list
        ../../gcc/gimplify.c:1869
0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14000
0x9f3705 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
0x9f3705 gimplify_statement_list
        ../../gcc/gimplify.c:1869
0x9f3705 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14000
0x9f9849 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
0x9f9849 gimplify_bind_expr
        ../../gcc/gimplify.c:1424
0x9f3102 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:13757
0x9f3705 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:6825
Please submit a full bug report,

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

end of thread, other threads:[~2021-03-24 12:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30 16:18 [Bug c++/98480] New: [coroutines] ICE on co_await in for-loop end condition dpsicilia at gmail dot com
2021-03-12 15:21 ` [Bug c++/98480] " iains at gcc dot gnu.org
2021-03-15 15:51 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:04 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:40 ` iains 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).