Closed yousefamar closed 8 years ago
@Paraknight: It's definitely not fine -- it returns a reference to a local variable :-)
_CPU_AND_GPU_CODE_ inline Matrix3& operator *(const T &r) const {
Matrix3 res(this->m);
return res *= r;
}
Once the local variable goes out of scope, you get a dangling reference, hence the observed behaviour.
I've fixed it in the infinitam_v3
branch on Victor's private fork.
@olafkaehler: Should we cherry-pick it across to master in the public fork?
That would be sensible. Go ahead!
Oh! I completely overlooked that. Thanks!
Fixed and merged
I'm not sure if I'm missing something obvious, but while writing unit tests I came across strange results and tracked it down to something that can be recreated like this:
The place that the * is overloaded is here, but that looks fine to me. l'd really appreciate another set of eyes on that.
I ran the above on a completely clean build of the master branch, though I also compiled with -DWITH_CUDA=FALSE but I don't think that's relevant.