On Tuesday 22 April 2014 17:45:08 Thiago Macieira wrote: > FAIL! : tst_QByteArray::reserve() 'qba.constData() != data' returned > FALSE. tst_qbytearray.cpp(1871) : failure location > > http://testresults.qt-project.org/ci/QtBase_stable_Integration/build_03694/w > in32-msvc2010_Windows_7/log.txt.gz
I had a quick look. You'll tell me if my hypothesis are correct. > Code around the location is: > > 1858 qba.resize(capacity); > [...] > 1863 QCOMPARE(qba.capacity(), capacity); > [...] > 1866 copy = qba; copy was still holding the original data. But there, it is assigned to detached version of itself, therefore the original data get freed. > 1867 qba.reserve(capacity * 2); Indeed we detach, but depending on the allocator, the memory of the original data might be re-used. (quite likely if the allocator uses a LIFO free list) > 1868 QCOMPARE(qba.size(), capacity); > 1869 QCOMPARE(qba.capacity(), capacity * 2); > 1870 QCOMPARE(copy.capacity(), capacity); > 1871 QVERIFY(qba.constData() != data); data here is a dangling pointer, and qba.constData() just happen to re-use this memory. -- Olivier Woboq - Qt services and support - http://woboq.com - http://code.woboq.org _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development