public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kacper.slominski72 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102508] ICE on coroutine when awaiting inside a statement expression (in transform_local_var_uses, at cp/coroutines.cc:2102)
Date: Thu, 21 Oct 2021 23:52:16 +0000	[thread overview]
Message-ID: <bug-102508-4-rFqjQAWgWt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102508-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Kacper Słomiński <kacper.slominski72 at gmail dot com> ---
Was about to report this myself; here is a minimal test case that reproduces
this issue without using any external libraries. It causes a slightly different
ICE in gimplify_expr in gimplify.c:14879 for GCC 11.2, but with small tweaks
you can get the one in transform_local_var_uses as well:

#include <coroutine>

struct coro {
        bool await_ready() { return true; }
        void await_suspend(std::coroutine_handle<>) { }
        int await_resume() { return 0; }

        struct promise_type {
                coro get_return_object() {
                        return {};
                }

                std::suspend_never initial_suspend() {
                        return {};
                }

                std::suspend_never final_suspend() noexcept {
                        return {};
                }

                template <typename T>
                void return_value(T &&) {}

                void unhandled_exception() {}
        };
};

coro fn() { co_return 1; };

coro foo() {
        ({
                auto ex = co_await fn();
                co_return ex;
        });
        co_return 0;
}

  parent reply	other threads:[~2021-10-21 23:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 21:58 [Bug c++/102508] New: " delleyves at gmx dot ch
2021-09-30  9:55 ` [Bug c++/102508] " marxin at gcc dot gnu.org
2021-10-21 23:52 ` kacper.slominski72 at gmail dot com [this message]
2021-10-22 20:11 ` iains 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-102508-4-rFqjQAWgWt@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).