Incorrect behavior of Eval(int& stackSize)
a-shahba opened this issue · 2 comments
a-shahba commented
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 commented
confirmed
beltoforion commented
fixed