tcbrindle / flux

A C++20 library for sequence-orientated programming
https://tristanbrindle.com/flux/
Boost Software License 1.0
441 stars 28 forks source link

strange output, [[2]] instead of [] #182

Closed andrey-budko closed 3 months ago

andrey-budko commented 3 months ago

https://flux.godbolt.org/z/MhGqKPjnr

#include <flux.hpp>
#include <iostream>

int main(){
    flux::iota(1,4)
        .drop(2)
        .reverse().drop(5).reverse()
        .filter([](int i) { return i&1; })
        .chunk(4)
        .write_to(std::cout);
    // [[2]]
}
tcbrindle commented 3 months ago

Hi @andrey-budko, thanks for the bug report. This is definitely a strange one!

Playing with the example, there are several interesting things:

There's definitely a bug... somewhere... but it looks like it's only exposed with a particular combination of adaptors.

tcbrindle commented 3 months ago

Hi @andrey-budko, this should now be fixed: https://flux.godbolt.org/z/o47dE8qbx

Thanks for the bug report, this was a fun one to track down! If you find any more Flux issues please do file them as well