Warning from static code analysis
Issue #26
resolved
Hi,
there is something suspicious about this code in nlopt_ik.cpp
if (grad!=NULL) {
for (uint i=0; i<n; i++) {
double o=vals[i];
vals[i]=o+jump;
double v1[m];
c->cartSumSquaredError(vals, v1);
vals[i]=o-jump;
double v2[m];
c->cartSumSquaredError(vals, v2);
vals[i]=o;
for (uint j=0; j<m; j++) {
grad[j*n+i]=(v1[j]-v2[j])/(2*jump);
}
}
}
First of all m is not known at compile time, and can't be used for C99 style arrays. if you really want a vector of size m you should use
std::vector<double> v1(m)
Comments (2)
-
reporter -
Account Deactivated - changed status to resolved
Thanks.
- Log in to comment
same of course for v2...