From 3ad7ddf265e67c5776147a8b8b3188ef61dfe5b3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 25 Nov 2011 10:53:38 +0100 Subject: Fix crash in tst_qatomicpointer test if given char*, QCOMPARE will try to compare the strings pointed by the char* In this case, the char* just point to garbage, we just want to compare the addresses. (Was changed in commit 6fcfae99d3615c7a850e4933691763097078c8e4) Change-Id: I9edb2b676aedf67a252aea6a41d56cd1eef7befc Reviewed-by: Bradley T. Hughes --- .../thread/qatomicpointer/tst_qatomicpointer.cpp | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'tests/auto/corelib/thread') diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index 5141bda4c2..73266205af 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -599,9 +599,10 @@ void tst_QAtomicPointer::fetchAndAdd() { QAtomicPointer pointer1 = pc; - QCOMPARE(pointer1.fetchAndAddRelaxed(valueToAdd), pc); - QCOMPARE(pointer1.fetchAndAddRelaxed(-valueToAdd), pc + valueToAdd); - QCOMPARE(pointer1.load(), pc); + // cast to void* in order to avoid QCOMPARE to compare string content of the char* + QCOMPARE(static_cast(pointer1.fetchAndAddRelaxed(valueToAdd)), static_cast(pc)); + QCOMPARE(static_cast(pointer1.fetchAndAddRelaxed(-valueToAdd)), static_cast(pc + valueToAdd)); + QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelaxed(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelaxed(-valueToAdd), ps + valueToAdd); @@ -614,9 +615,9 @@ void tst_QAtomicPointer::fetchAndAdd() { QAtomicPointer pointer1 = pc; - QCOMPARE(pointer1.fetchAndAddAcquire(valueToAdd), pc); - QCOMPARE(pointer1.fetchAndAddAcquire(-valueToAdd), pc + valueToAdd); - QCOMPARE(pointer1.load(), pc); + QCOMPARE(static_cast(pointer1.fetchAndAddAcquire(valueToAdd)), static_cast(pc)); + QCOMPARE(static_cast(pointer1.fetchAndAddAcquire(-valueToAdd)), static_cast(pc + valueToAdd)); + QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddAcquire(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddAcquire(-valueToAdd), ps + valueToAdd); @@ -629,9 +630,9 @@ void tst_QAtomicPointer::fetchAndAdd() { QAtomicPointer pointer1 = pc; - QCOMPARE(pointer1.fetchAndAddRelease(valueToAdd), pc); - QCOMPARE(pointer1.fetchAndAddRelease(-valueToAdd), pc + valueToAdd); - QCOMPARE(pointer1.load(), pc); + QCOMPARE(static_cast(pointer1.fetchAndAddRelease(valueToAdd)), static_cast(pc)); + QCOMPARE(static_cast(pointer1.fetchAndAddRelease(-valueToAdd)), static_cast(pc + valueToAdd)); + QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelease(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelease(-valueToAdd), ps + valueToAdd); @@ -644,9 +645,9 @@ void tst_QAtomicPointer::fetchAndAdd() { QAtomicPointer pointer1 = pc; - QCOMPARE(pointer1.fetchAndAddOrdered(valueToAdd), pc); - QCOMPARE(pointer1.fetchAndAddOrdered(-valueToAdd), pc + valueToAdd); - QCOMPARE(pointer1.load(), pc); + QCOMPARE(static_cast(pointer1.fetchAndAddOrdered(valueToAdd)), static_cast(pc)); + QCOMPARE(static_cast(pointer1.fetchAndAddOrdered(-valueToAdd)), static_cast(pc + valueToAdd)); + QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddOrdered(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddOrdered(-valueToAdd), ps + valueToAdd); -- cgit v1.2.3