mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
Compare nullness in Hypothesis::RecombineCompare.
The comparison code subtracted two pointers in the case where at least one was null, to get a signed int comparison result. But that subtraction is undefined, and the cast to int (dropping the most-significant bits!) made the outcome even less uncertain. In this patch I compare the nullness of the pointers instead, which should always return a well-defined -1, 0, or 1.
This commit is contained in:
parent
0ca2bcb28d
commit
d4508e984f
@ -213,7 +213,8 @@ RecombineCompare(const Hypothesis &compare) const
|
|||||||
|
|
||||||
for (unsigned i = 0; i < m_ffStates.size(); ++i) {
|
for (unsigned i = 0; i < m_ffStates.size(); ++i) {
|
||||||
if (m_ffStates[i] == NULL || compare.m_ffStates[i] == NULL) {
|
if (m_ffStates[i] == NULL || compare.m_ffStates[i] == NULL) {
|
||||||
comp = m_ffStates[i] - compare.m_ffStates[i];
|
// TODO: Can this situation actually occur?
|
||||||
|
comp = int(m_ffStates[i] != NULL) - int(compare.m_ffStates[i] != NULL);
|
||||||
} else {
|
} else {
|
||||||
comp = m_ffStates[i]->Compare(*compare.m_ffStates[i]);
|
comp = m_ffStates[i]->Compare(*compare.m_ffStates[i]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user