Re: transform-reduce compiling with seq but not par - bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 18 Dec 2020, 22:35 Kai via Gcc-help, <gcc-help@xxxxxxxxxxx> wrote:

> Morning!
>
> I've got a transform-reduce statement that compiles with execution::seq.
> When replacing the policy parameter with execution::par, I get a compile
> time error. This seems odd to me and I'm seeking advice here whether to
> file a bug report with gcc or not.
>
> The environment is a gcc 10.2 on an arch linux derivate; libstdc++ has
> version 6.0.28 (owned by package gcc-libs 10.2.0-3); libtbb is in use
> (owned by package tbb 2020.3-1).
>
> The statement in questions reads (in a simplified example):
> Obj x = transform_reduce( execution::par, v.begin(), v.end(), Obj{0},
>                           [](Obj &a,Obj const &b) { a.combine(b); return
> move(a); },
>                           [](int i){ return Obj{i}; }  );
>
> ( overload 6: https://en.cppreference.com/w/cpp/algorithm/transform_reduce
> )
>
> Pls find the compiler error at the end of this mail; seems to be in the
> interface to TBB. On the compiler explorer, this behaviour is
> reproducible, when TBB is selected as additional library. It compiles
> (and runs) OK there without the TBB.
> Might this be a bug in gcc's interface to TBB?
>


No, I don't think this is a bug in GCC. Your unary_op returns by value,
which means it cannot be the first argument for your binary_op, because
that requires a non-const lvalue.

It should work if you change your first lambda to:

[](Obj a,Obj const &b) { a.combine(b); return a; }


>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux