Segmentation fault: 11 error occurred in a circular statement
the platform version of the problem and what methods you have tried
platform version: MacOSX 10.14
tried method: check to see if any memory has not been freed; check to see if there is cross-boundary access
related codes
isOperator definition
void BerryMath::expr::parse_expr(std::string s)
{
if (p != 0x0 && --p->use == 0) {
delete p;
}
// Remove blank
int i = 0;
while (i < s.length() && BerryMath::isSpace(i)) {
iPP;
}
std::string token = "";
token = "";
// Get the first value
while (i < s.length() && !BerryMath::isOperator(s[i])) {
token += s[i];
iPP;
}
std::string v = token;
std::cout << token << std::endl;
// std::cout << token << std::endl;
token = "";
// Get the operator
while (i < s.length() && BerryMath::isSymbol(s[i])) {
token += s[i];
iPP;
}
std::string op = token;
// Remove blank
while (i < s.length() && BerryMath::isSpace(s[i])) {
iPP;
}
// Get the next operator
while (i < s.length() && BerryMath::isSymbol(s[i])) {
token += s[i];
iPP;
}
std::string nextOp = token;
// Get the next expression
token = "";
for ( ; i < s.length() ; iPP) {
token += s[i];
}
BerryMath::expr test(op,v);
if (!token.empty()) {
BerryMath::expr a("");
a.parse_expr(token);
*this = BerryMath::expr(
nextOp,
test,
a
);
} else {
*this = BerryMath::expr(
op,
v
);
}
// std::cout << *this << std::endl;
}
I expect the syntax tree to be created successfully, but there is an error of Segmentation fault: 11