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

--- Comment #2 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
this is a double-free it would seem.

but, the following works:

#include <array>
#include <generator>
#include <ranges>
#include <vector>

using namespace std;

template <ranges::input_range Range1, ranges::input_range Range2>
[[nodiscard]] auto
concat(Range1&& range1, Range2&& range2) -> generator<int, int>
{
  co_yield ranges::elements_of(range1);
  co_yield ranges::elements_of(range2);
}

auto
main() -> int
{
  auto const numbers1 = array{0};
  auto const numbers2 = vector{0};
  for (auto const _: concat(numbers1, numbers2) ) {}
}

... which is quite intriguing.. is this equivalent to the first example?

Reply via email to