tcbrindle/flux

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

andrey-budko opened this issue · 2 comments

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]]
}

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

Playing with the example, there are several interesting things:

  • If we remove the chunk() adaptor, it prints an empty sequence as expected
  • If we remove the filter(), we get an empty sequence
  • If we remove the second reverse(), we get an empty sequence
  • If we move the filter so that it's the first adaptor in the pipeline (directly after the iota), we get an empty sequence
  • If we swap the filter with the second reverse, then we get an empty sequence

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

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