[PATCH] Fix segfault in HashCode() (subtitle: implicit conversions considered harmful)

Hello,

The code below segfaults on Linux when MMGT_OPT is set to 0 or 2:

#include
#include

int main(int argc, char **argv) {
Standard_Transient s;
Standard_Integer i = s.HashCode(1000);
std::cout return 0;
}

The current implementation calls HashCode(Handle_Standard_Transient,Standard_Integer)
due to implicit conversion operator. But if object is allocated on the stack,
a segmentation fault occurs when the Handle_Standard_Transient temporary object
is deleted. This happens if MMGT_OPT is set and different from 1.

Implicit conversions should really be forbidden in order to avoid those subtle bugs.

Attachments: 
Forum supervisor's picture

Dear Denis,
The reported problem is checked and reproduced.
The corresponding issue with ID = 22749 has been registered.
Later you can know if the issue is resolved by checking references to the specified ID in OCCT Release Notes. The analysis of the issue will take some time depending on our technical capability and availability of resources.
Thanks for your contribution.
Regards