Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.7.2, 4.8.0
-
None
-
MSVC 2010 (Qt 4.8) and MSVC 2008 (Qt 4.7.2)
Description
--snip--
QList<int> test;
if (test.begin() == test.constBegin())
doSomething();
if (test.begin() == test.constBegin())
doSomethingElse();
--snip--
Only doSomethingElse() will be executed. If comparisons are written by settings constBegin() first and begin() last, then both are executed.
AFAIK this happens because list has internal reference count of zero and therefore begin() runs detach() on first run and test.constBegin() is executed first.
I don't know if this should be fixed or just documented to API, but currently it works bit dangerously (even though users should not mix constBegin() and begin(), or constBegin() and end()).
I understand API like this comparison should be valid in all cases no matter how smart it is since iterator has operator==(const const_iterator& other) const.