[Qt-interest] Unexpected behaviour for loop

Malyushytsky, Alex alex at wai.com
Sat May 30 04:29:01 CEST 2009


It also depends on the compiler you are using,

If it support later standard 'i' will be a local variable which will be destroyed  out of }  scopes after for statement.
You have no body , so it will never is coing to be even initialized

If you had MSVC6 the below code, 'i' would be considered out of scope variable and you would have it initialized anyway



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Parker
Sent: Thursday, May 28, 2009 12:56 AM
To: Andreas Pakulat; qt-interest at trolltech.com
Subject: Re: [Qt-interest] Unexpected behaviour for loop

Heh, that's it.
It seems it was an optimization... thank you :)

----- Original Message -----
From: "Andreas Pakulat" <apaku at gmx.de>
To: <qt-interest at trolltech.com>
Sent: Thursday, May 28, 2009 10:43 AM
Subject: Re: [Qt-interest] Unexpected behaviour for loop


> On 28.05.09 10:28:17, Parker wrote:
>> Hello,
>> I noticed something strange while using the for loop. Here :
>>
>>  for(int i = 1;i < integerList.size();i++)
>> {
>>
>>
>> }
>>
>>
>>
>> "i" should be initialized to 1 and we should enter the loop. But it's not
>> happenig. I debuged, the i variable is just not initialized.
>
> How did you test that? And if you don't have a body in your loop, then
> your compiler may optimize the whole loop out of your application when
> building with optimizations enabled.
>
> Andreas
>
> --
> Be cheerful while you are alive.
> -- Phathotep, 24th Century B.C.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4098 (20090522) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4098 (20090522) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list