|
Probably jus some lazy programmer included it in his standard library.
|
|
|
|
|
Or maybe a side effect of "Made In China" ? ? ?
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
When I buy a pre-built machine or laptop, I ALWAYS install a different copy of Windows on it as opposed to leaving their crapware-filled OS on the box. Then I let Windows update take care of the drivers.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Quote: I ALWAYS install a different copy of Windows Ditto for me!
Get me coffee and no one gets hurt!
|
|
|
|
|
So, I'm testing some ftp s/w on Windows. Standard code, details deliberately dropped:
handle myHandle = FtpFindFirstFile();
if (NULL != myHandle)
{
do
{
} while (InternetFindNextFile());
}
I'm in the debugger, I just want to see the values in some data structures. Code keeps dropping right out of the do loop. Code steps in, loop exits, I know there are more files matching than just the first... wth is going on?
duh, compiler be too smart - nothing in the do loop, why bother? Add a variable increment in the loop, all works. so much time lost
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Welcome to optimization.
|
|
|
|
|
I have never seen the compiler "optimize" code away in debug mode. That is very curious.
-edit-
That's because optimization is usually disabled in debug builds. I would verify that it is, in fact, disabled.
modified 11-Dec-17 17:54pm.
|
|
|
|
|
optimization is off....
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
charlieg wrote: Add a variable increment in the loop, all works.
Sooo, why shouldn't the compiler optimize it out? You're not doing anything with the next file, and the compiler shouldn't have to know that there is some side-effect effect. To be honest, I'd look at that code and go WTF? myself.
|
|
|
|
|
Marc Clifton wrote: Sooo, why shouldn't the compiler optimize it out? You're not doing anything with the next file, and the compiler shouldn't have to know that there is some side-effect effect. Optimising compilers must be aware of side effects; it's one of the factors that makes optimising REALLY difficult (NP-complete or worse). Optimisation involve producing a semantically equivalent program while minimising or maximising some aspect - run time, memory size, power usage, ...
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I don't really have an argument with the compiler - with the exception that optimizations are not enabled for the debug target. Since I'm sitting in the debugger, I would have expected the do nothing loop to loop as expected.
I'm making a function call ffs in the control statement. If an optimized build, sure. But I was just knocking around some proof of concept code to understand how all things worked.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I've seen that many many times. Be sure optimizations are turned off.
|
|
|
|
|
see above. it's a non-optimized debug target.
I'm sure there is some esoteric reason why the C++ compiler is not in error.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Then your assumption that InternetFindNextFile() works as expected must be wrong. Step into it and see what it does.
I have lived with several Zen masters - all of them were cats.
|
|
|
|
|
From a distant point of view, it might as well be a debugger bug (oh, how ironic)...
Or a compiler bug, where turning of optimization doens't turn off optizing away your bit there.
Have you reported the behavior?
I only have a signature in order to let @DalekDave follow my posts.
|
|
|
|
|
Hmmm... seems quite odd, I never saw MSVC remove any code in debug builds.
Could it be a timing issue (helped by your increment, no matter how unlikely)?
Did you check the generated code?
... such stuff as dreams are made on
|
|
|
|
|
Is pasteurize too far to see?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
"Would you like it pastuerised, 'cos pasteurised is best"
"Quite frankly I'd be happy if it came up to my chest"
|
|
|
|
|
'Is name was Ernie, and 'e drove the fastest milkcart in the West!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
And that was the first time that I helped a soldier to desert!
|
|
|
|
|
Oh well here today gone to Maui!
Someone's therapist knows all about you!
|
|
|
|
|
No, that's just the end of your nose.
|
|
|
|
|
You wouldn't dairy get involved with homogenized (I remark sheepishly).
Instead, we curd continue with further cheesy remarks.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Yogurt to butter up on them lest they udderly fail to milk out the laughter you so moovingly seek.
|
|
|
|
|
I do 30 minutes of yogurt every day to make myself more limberger.
If anyone needs some holiday candy canes I have some, not broken either, they're in "mint" condition.
|
|
|
|