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

            Bug ID: 117231
           Summary: Incorrect code generation for std::generator
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: winmikedows at hotmail dot com
  Target Milestone: ---

With GCC trunk, the following minimal usage of std::generator results in
incorrect code:
```cpp
#include <generator>
#include <print>
#include <vector>

std::generator<int> get_seq()
{
    std::vector<int> data_{1, 2, 3};
    for (auto item : data_)
        co_yield item;
}

int main()
{
    for (auto item : get_seq())
        std::println("{}", item);
}
```
The expected result, and what is outputted by GCC 14.2, is "1 2 3" on three
lines. However, with the GCC trunk, only a single 0 is outputted. See
https://godbolt.org/z/fE1593c9h.

Reply via email to