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

Incorrect behavior of Eval(int& stackSize) #94

Closed
a-shahba opened this issue Jan 19, 2021 · 2 comments
Closed

Incorrect behavior of Eval(int& stackSize) #94

a-shahba opened this issue Jan 19, 2021 · 2 comments
Labels

Comments

@a-shahba
Copy link

Comparing v2.2.6 with v2.3.2, there is a change in the behavior of Eval(int& stackSize) which is most likely a bug. When the expression has only a single return value, Eval(int& stackSize) always returns 0. The following code demonstrates this issue

#include <iostream>
#include <string>
#include "muParser.h"

int main(){

    double p1, p2;
    int nc1, nc2;

    mu::Parser parser1;
    parser1.DefineVar("X", &p1);
    parser1.SetExpr("10.0");

    mu::Parser parser2;
    parser2.DefineVar("X", &p2);
    parser2.SetExpr("X + 2");

    std::cout << "\nParser1: Expected to be 10\n";
    p1 = 1.0;
    auto val1 = parser1.Eval(nc1);
    for (unsigned ii = 0; ii < nc1; ++ii) {
        std::cout << ii << "-th component:" << val1[ii] << std::endl;
    }

    std::cout << "\nParser2: Expected to be 12\n";
    p2 = 10;
    auto val2 = parser2.Eval(nc2);
    for (unsigned ii = 0; ii < nc2; ++ii) {
        std::cout << ii << "-th component:" << val2[ii] << std::endl;
    }

    return 0;
}
@beltoforion beltoforion added the bug label Jun 7, 2021
@beltoforion
Copy link
Owner

confirmed

beltoforion pushed a commit that referenced this issue Jun 7, 2021
Stack variable renamed to stack (style violation)
@beltoforion
Copy link
Owner

fixed

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

No branches or pull requests

2 participants