[Interest] QXmlStreamReader and qDebug()
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Sat Jul 27 01:39:13 CEST 2013
Il 27/07/2013 00:51, Alexander Syvak ha scritto:
> operator<< is evaluated from the left to the right each time returning
> QDebug object.
That's only half of the story. When in your code you have something like
this:
qDebug() << a << b << c;
that will get parsed by the compiler into something like this:
operator<<(operator<<(operator<<(qDebug(), a), b), c);
Now, what's the order of evaluation of the parameters of topmost
operator<< call? That's it: C++ leaves it to the implementation.
Under x86, for various reasons (*), arguments gets evaluated right to
left and pushed to the stack in that order. That means c gets evaluated
before b, and b before a. If a, b, c are function calls that modify a
global state, your results will be... unexpected. Which is what you're
experiencing.
(*) for instance, for being able to implement variadic functions more
easily: the known parameters are on the top of the stack.
Hope this helps,
--
Join us at Qt Developer Days 2013! - https://devdays.kdab.com
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4048 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130727/c229654d/attachment.bin>
More information about the Interest
mailing list