Skip to content

Commit c697883

Browse files
Fixed failures in openfhe-python tests linked with clang++-18 (#972)
Co-authored-by: Dmitriy Suponitskiy <dsuponitskiy@dualitytech.com>
1 parent 88dc4c5 commit c697883

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/core/include/lattice/hal/default/ildcrtparams.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,22 @@ class ILDCRTParams final : public ElemParams<IntType> {
286286
* @return the equality check results.
287287
*/
288288
bool operator==(const ElemParams<IntType>& other) const override {
289-
const auto* dcrtParams = dynamic_cast<const ILDCRTParams*>(&other);
290-
if (!dcrtParams)
289+
// ATTENTION: the following changes was made to fix failures in openfhe-python tests linked with clang++-18
290+
// ========================================================================================================
291+
// make sure that "other" is of the ILDCRTParams<IntType> datatype as we have to "static_cast" it.
292+
// dynamic_cast doesn't work. only after removing "final" from ILDCRTParams, dynamic_cast starts working.
293+
// it suggests that clang handles "final" differently in templates. most likely, it optimizes some things
294+
// more aggressively, which affects RTTI and base class behavior (especially in templates).
295+
if (typeid(other) != typeid(ILDCRTParams<IntType>))
291296
return false;
292-
if (ElemParams<IntType>::operator==(other) == false)
297+
const auto& dcrtParams = static_cast<const ILDCRTParams<IntType>&>(other);
298+
299+
if (ElemParams<IntType>::operator==(dcrtParams) == false)
293300
return false;
294-
if (m_params.size() != dcrtParams->m_params.size())
301+
if (m_params.size() != dcrtParams.m_params.size())
295302
return false;
296303
for (size_t i = 0; i < m_params.size(); ++i) {
297-
if (*m_params[i] != *dcrtParams->m_params[i])
304+
if (*m_params[i] != *(dcrtParams.m_params[i]))
298305
return false;
299306
}
300307
return true;

0 commit comments

Comments
 (0)