From 96e4469f657a71db8246247fd7534552fcb7d22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Edelbo?= Date: Thu, 19 Sep 2024 14:04:37 +0200 Subject: [PATCH] Fix comparison function for ConditionType The function should ensure strict weak ordering. According to the current one {1, 0} == {0, 1} and {0, 1} == {2, 1} but {1, 0} < {2, 1} It is not possible to construct a failing test as the outcome very much depends on how the runtime types are laid out. --- CHANGELOG.md | 2 +- src/realm/query_engine.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc80c40338..44c7a8218ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * None. ### Fixed -* ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) +* Having a query with a number of predicates ORed together may result in a crash on some platforms (strict weak ordering check failing on iphone) ([#8028](https://github.com/realm/realm-core/issues/8028), since v14.6.0) * None. ### Breaking changes diff --git a/src/realm/query_engine.hpp b/src/realm/query_engine.hpp index 39d39b43a5a..573405b03ee 100644 --- a/src/realm/query_engine.hpp +++ b/src/realm/query_engine.hpp @@ -2268,7 +2268,7 @@ class OrNode : public ParentNode { std::type_index m_type; bool operator<(const ConditionType& other) const { - return this->m_col < other.m_col && this->m_type < other.m_type; + return (this->m_col == other.m_col) ? this->m_type < other.m_type : this->m_col < other.m_col; } bool operator!=(const ConditionType& other) const {