MantisBT - Open CASCADE
View Issue Details
0030608Open CASCADE[OCCT] OCCT:Foundation Classespublic2019-03-26 15:142020-10-05 16:58
tizmaylo 
kgv 
normalminor 
newopen 
[OCCT] 7.3.0 
[OCCT] 7.6.0* 
0030608: Foundation Classes - Undefined behavior caused by overflow in arithmetic operations with signed integers in HashCode() functions
There is a number of places in the code of HashCode() functions where an overflow in arithmetic operations with signed integers may possibly occur. E.g., look at BRepMesh_Triangle::HashCode:

inline Standard_Integer HashCode(const Standard_Integer theUpper) const
{
  return ::HashCode(myEdges[0] + myEdges[1] + myEdges[2], theUpper);
}

There are three signed integer that are summed up. If they would big enough, an overflow might occur. But in accordance with the C++ standard a signed integer arithmetic overflow is an undefined behavior.
No tags attached.
related to 0030550closed bugmaster Community Coding - Integer overflow in Standard_CString HashCodes 
Issue History
2019-03-26 15:14tizmayloNew Issue
2019-03-26 15:14tizmayloAssigned To => kgv
2019-03-26 15:14tizmayloRelationship addedrelated to 0030550
2019-09-04 18:27kgvSummaryUndefined behavior caused by overflow in arithmetic operations with signed integers in HashCode() functions => Foundation Classes - Undefined behavior caused by overflow in arithmetic operations with signed integers in HashCode() functions
2019-09-05 04:52abvTarget Version7.4.0 => 7.5.0
2020-08-28 14:31kgvTarget Version7.5.0 => 7.6.0*

There are no notes attached to this issue.