Код: Выделить всё
#include
#include
#include
#include
auto loop(std::ranges::view auto ints) -> void
{
for (auto it = ints.begin(); it != ints.end(); ++it)
{
if (it != ints.begin())
{
(void) std::prev(it);
}
}
}
int main()
{
std::vector ints;
ints.push_back(1);
ints.push_back(2);
loop(ints | std::views::transform([](auto i) { return i; }));
}
< /code>
Код выше дистиллирован из фактического кода, который я написал. Он хорошо компилирует, но он либо сбои, либо, кажется, входит в бесконечный цикл во время выполнения.#0 0x00005555555557b6 in std::ranges::transform_view::_Iterator::operator++(void) (this=0x7fffffffe630) at /usr/include/c++/13/ranges:1836
#1 0x0000555555555800 in std::__advance(std::ranges::transform_view::_Iterator &, long, std::input_iterator_tag) (__i=..., __n=-751756672) at /usr/include/c++/13/bits/stl_iterator_base_funcs.h:163
#2 0x00005555555556c2 in std::advance (__n=-1, __i=...) at /usr/include/c++/13/bits/stl_iterator_base_funcs.h:224
#3 std::prev (__n=1, __x=...) at /usr/include/c++/13/bits/stl_iterator_base_funcs.h:250
#4 loop(std::ranges::transform_view) (ints=...)
at /main.cpp:13
#5 0x000055555555545a in main () at /main.cpp:24
msvc)
Есть ли дефект на языке? Вызванный.
Подробнее здесь: https://stackoverflow.com/questions/797 ... -on-vector
Мобильная версия