From 8226ae9ac70e48c32cc7595ec8346df038f3b325 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Aug 2022 12:38:40 -0300 Subject: [PATCH] tst_QMap: avoid tripping MSVC debug-mode iterator assertions It does a check to ensure you aren't comparing outside the container. Fixes: QTBUG-106001 Change-Id: Ic6547f8247454b47baa8fffd170eef346b7f4f24 Reviewed-by: Giuseppe D'Angelo (cherry picked from commit f039147165049dedcf6e1d92d902af28f566d753) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 589b98ce497..695d9801ceb 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -422,7 +422,12 @@ void tst_QMap::beginEnd() // detach map2.insert( "2", "c" ); QVERIFY( map.constBegin() == map.constBegin() ); - QVERIFY( map.constBegin() != map2.constBegin() ); + + // comparing iterators between two different std::map is UB (and raises an + // assertion failure with MSVC debug-mode iterators), so we compare the + // elements' addresses. + QVERIFY(&map.constBegin().key() != &map2.constBegin().key()); + QVERIFY(&map.constBegin().value() != &map2.constBegin().value()); } void tst_QMap::firstLast()