-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension of lifetime within tensor expression templates for prvalues not guaranteed. #125
Labels
Comments
bassoy
changed the title
Bug in Tensor Expression Templates
Extension of lifetime within tensor expression templates for prvalues not guaranteed.
Sep 6, 2021
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. |
amitsingh19975
added a commit
that referenced
this issue
Feb 9, 2022
Fix for issue #125. The current implementation does not take into account the prvalue that creates an issue while storing it. The prvalue is destroyed after the end of its scope, and if you try access it, you are entering into undefined land of C++. To solve this issue, we employ the trait `std::is_lvalue_reference` to determine if need to extend the lifetime or not. If extension is needed, we store the value with the help of universal forwarding. Otherwise, we extend lifetime using `const &`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
toxvalue
expression conversion, see also temporary materialization and value categorization.In case of
prvalue
expressions such as42
or42+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 theprvalue
is passed without materialization.Possible fixes are
value_type
instead ofconst_reference
in expressions such as inublas/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp
Line 291 in db29cdf
The text was updated successfully, but these errors were encountered: