From f039147165049dedcf6e1d92d902af28f566d753 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Aug 2022 12:38:40 -0300 Subject: 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 Pick-to: 6.2 6.3 6.4 Change-Id: Ic6547f8247454b47baa8fffd170eef346b7f4f24 Reviewed-by: Giuseppe D'Angelo --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 554366ce3d..d4f886784d 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -429,7 +429,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() -- cgit v1.2.3