http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57997

--- Comment #4 from Roy Stogner <roystgnr at ices dot utexas.edu> ---
I oversimplified the code here to try and make the failure as easy to
reproduce as possible.  The term here isn't con-fusion, it's "kernel
fusion", which the original user code is trying to do with libstdc++
valarray expressions (and VexCL expressions, and Eigen expressions,
etc; those cases work); this is essentially the opposite of assuming
that expression templates match their input types.  To keep equations
in their own functions (for maintainability) while still doing
parallel evaluation in a single loop (for efficiency), those functions
need to return the expression templates which embody their equations.

However, this does assume that expression template move constructors
(or copy constructors if move constructors aren't defined) don't do a
shallow copy of the representations of subexpression objects, and I
can't see anything in C++2011 or C++2014 standards drafts *mandating*
anything about those constructors.  If my amateur standards-lawyering
is correct, it would be fair for you to mark this as "wontfix" or
whatever bugzilla term signifies "go_bug_standards_committee_instead".

On the third hand, there's nothing in the current standard mandating
that the implementation *not* be robust when doing kernel fusion with
user functions, either.  Storing subexpressions by value in _BinBase
(specializing to store by reference when the subexpression is just a
valarray) might be a sufficient fix.

Reply via email to