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:
+10
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user