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

            Bug ID: 115914
           Summary: SIGSEGV when std::generator co_yield different ranges
                    of elements
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

#include <generator>
#include <ranges>
#include <iostream>
#include <vector>

template<std::ranges::input_range... Rs>
auto concat(Rs&&... rs) -> std::generator<const int&> {
  (co_yield std::ranges::elements_of(rs), ...);
}

int main() {
  std::vector v{1, 2, 3};
  auto r = std::views::iota(4, 10);
  for (int i : concat(v, r))
    std::cout << i << ' ';
}

GCC emits SIGSEGV, while Clang outputs the expected results.

https://godbolt.org/z/33h5TThea

Reply via email to