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

            Bug ID: 123975
           Summary: Crash when await_suspend takes an r-value (&&)
                    argument
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: maddimax at gmail dot com
  Target Milestone: ---

Please see: https://godbolt.org/z/513c39dYz

GCC 14, and clang 21.1.0 compile and run the code without issues. GCC 15.1 &
15.2 run into an SIGBUS error when trying to access p.value. As a workaround,
change the argument `h` to a value solves the issue. I'm still quite new to
coroutines so it might just be a bug in the code, but since GCC14 & Clang don't
show the issue I think it might be a valid issue.

```
//#if __GNUC__ >= 15
//    void await_suspend(auto h) {
//#else
    void await_suspend(auto &&h) {
//#endif
        auto p = h.promise();
        p.value->emplace(std::unexpected{value.error()});
    }
```

Please let me know if I can provide any other material.

Cheers,
Marcus

Reply via email to