Skip to content
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

Revise rvalue objects handling #71

Open
drewdzzz opened this issue Nov 23, 2023 · 0 comments
Open

Revise rvalue objects handling #71

drewdzzz opened this issue Nov 23, 2023 · 0 comments

Comments

@drewdzzz
Copy link
Collaborator

Consider a simple snippet:

auto a = mpp::as_arr(std::vector<int>{1, 2, 3});
std::cout << mpp::unwrap(a)[1] << std::endl;

Output is... 21852! And valgrind writes about invalid access to deallocated memory.
The reason is storing object as T&& in our wrappers. But T&& is also a reference (which is definitely going to be expired), so we should store passed rvalue object by value (T).

All the places handling both lvalue and rvalue objects should be revised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant