Watch out for undefined behaviour.

This commit is contained in:
Tiago Gomes 2013-03-18 16:18:47 +00:00
parent c550139c8b
commit da88ffcc78

View File

@ -179,12 +179,13 @@ Factor::sumOutLastVariable()
Params::iterator last = params_.end();
if (Globals::logDomain) {
while (first2 != last) {
// the arguments can be swaped, but that is ok
*first1++ = Util::logSum (*first2++, *first2++);
double tmp = *first2++;
*first1++ = Util::logSum (tmp, *first2++);
}
} else {
while (first2 != last) {
*first1++ = (*first2++) + (*first2++);
*first1 = *first2++;
*first1++ += *first2++;
}
}
params_.resize (params_.size() / 2);