Extension of lifetime within tensor expression templates for prvalues not guaranteed.
The current expression template implementation binds rvalue expressions to const references.
In such cases the lifetime of designated temporary objects are automatically extended due to prvalue to xvalue expression conversion, see also temporary materialization and value categorization.
In case of prvalue expressions such as 42 or 42+13, it seems that such a lifetime extension dos not work such that tensor expressions are not correctly evaluated although tensor expression objects are never copied. We suspect that this bug results from the mandatory copy elision rules as the prvalue is passed without materialization.
Possible fixes are
- to use
value_typeinstead ofconst_referencein expressions such as in https://github.com/boostorg/ublas/blob/db29cdf76cdd4c3732164c99e9a22e9e02bf994f/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp#L291 - or to distinguish between tensor element and tensor types, see also this example
Hello! If there is no ongoing work done on this issue by anyone, then can i try to fix this issue. Kindly assign it to me if no one is working on it.