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

Handling of temporaries in CLEF #78

Open
Thoemi09 opened this issue Sep 18, 2024 · 0 comments
Open

Handling of temporaries in CLEF #78

Thoemi09 opened this issue Sep 18, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Thoemi09
Copy link
Contributor

Description

When CLEF evaluates an expression, it tries to avoid unnecessary copies by moving objects whenever possible. This can lead to problems, when temporary objects are assigned to placeholders.

Steps to Reproduce

using namespace nda::clef::literals;
auto ex = i_ + i_;
nda::vector<int> vec = clef::eval(ex, i_ = nda::vector<int>{1, 2});
std::cout << vec << std::endl;

Expected behavior:

[2,4]

Actual behavior:

Segmentation fault: 11

The same problem arises, when we do partial evaluations:

using namespace nda::clef::literals;
auto ex = i_[0] + j_;
auto ex2 = clef::eval(ex, i_ = std::vector{1, 2, 3});
std::cout << clef::eval(ex2, j_ = 1) << std::endl;

Expected behavior:

2

Actual behavior:

1
@Thoemi09 Thoemi09 added the bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants