public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95822] New: [coroutines] compiler internal error with local object with noexcept false destructor
@ 2020-06-22 18:51 victor.burckel at gmail dot com
  2020-06-23  9:06 ` [Bug c++/95822] " iains at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: victor.burckel at gmail dot com @ 2020-06-22 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95822
           Summary: [coroutines] compiler internal error with local object
                    with noexcept false destructor
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: victor.burckel at gmail dot com
  Target Milestone: ---

It seems that when a coroutine contains a local object whose destructor is
marked as noexcept(false), gcc reaches an unexpected state and aborts.
When compiling the following code with gcc10.1.0 (-std=c++20 -fcoroutines), I
get a compiler internal error: 
> internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:2830

Making the destructor noexcept fixes the error. I  got the error when using
boost log within a couroutine. It uses a record_pump whose destructor is not
noexcept.

I managed to reproduce with godbolt (both gcc10.1 and gcc trunk give me the
assertion)
https://godbolt.org/z/6JtKsU

#include <coroutine>

struct task {
  struct promise_type {
    auto initial_suspend() noexcept { return std::suspend_always{}; }
    auto final_suspend() noexcept { return std::suspend_always{}; }
    void return_void() {}
    task get_return_object() { return task{}; }
    void unhandled_exception() noexcept {}
  };

  ~task() noexcept {}

  bool await_ready() const noexcept { return false; }
  void await_suspend(std::coroutine_handle<>) noexcept {}
  void await_resume() noexcept {}
};

struct Error {
  ~Error() noexcept(false) {}
};

task g();
task f() {
  Error error;
  co_await g();
}

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

end of thread, other threads:[~2021-07-18 23:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 18:51 [Bug c++/95822] New: [coroutines] compiler internal error with local object with noexcept false destructor victor.burckel at gmail dot com
2020-06-23  9:06 ` [Bug c++/95822] " iains at gcc dot gnu.org
2020-07-23  6:51 ` rguenth at gcc dot gnu.org
2021-02-16  9:12 ` iains at gcc dot gnu.org
2021-02-25 19:34 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:03 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:42 ` iains at gcc dot gnu.org
2021-07-18 23:48 ` pinskia 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).