On segunda-feira, 11 de novembro de 2013 13:37:20, Samuel Gaist wrote: > Hi, > > I have been experiencing a strange behavior with QStringList and the order > of execution of takeFirst.
> qDebug() << lineData.takeFirst() << lineData.takeFirst(); The problem is not takeFirst. > behaves differently on two computers. Correct. You have undefined behaviour. Both calls to takeFirst() are in the same "sequence-point". That means the compiler is allowed to execute in any order. It would be the same if you had written: f(lineData.takeFirst(), lineData.takeFirst()); > qDebug() << lineData.takeFirst(); > qDebug() << lineData.takeFirst(); > > The order is correct on both of them. > > What could explain the difference ? In the second case, there are two sequence points (they are separated by a ;). In C++11-speak, the first line of the second example is guaranteed to "happens- before" the second line. In the first example, there's no "happens-before", therefore any one can happen before the other, or after. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest