Fix strict weak ordering violation in ASSERT_CACHE_KEY::operator<

The comparator used logical OR between field comparisons, which
violates the asymmetry requirement of strict weak ordering. Two
keys with different orderings across fields could both compare as
less-than each other, causing undefined behavior in the std::set
that deduplicates assert messages.

Replace with proper lexicographic comparison.
This commit is contained in:
Seth Hillbrand
2026-02-19 07:42:19 -08:00
parent e6a7ea14da
commit 3d2235f97a
+10 -1
View File
@@ -320,7 +320,16 @@ SENTRY* SENTRY::m_instance = nullptr;
bool operator<( const ASSERT_CACHE_KEY& aKey1, const ASSERT_CACHE_KEY& aKey2 )
{
return aKey1.file < aKey2.file || aKey1.line < aKey2.line || aKey1.func < aKey2.func || aKey1.cond < aKey2.cond;
if( aKey1.file != aKey2.file )
return aKey1.file < aKey2.file;
if( aKey1.line != aKey2.line )
return aKey1.line < aKey2.line;
if( aKey1.func != aKey2.func )
return aKey1.func < aKey2.func;
return aKey1.cond < aKey2.cond;
}