Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

time delay loops?

Name: Anonymous 2008-03-31 7:59

hey /prog/
sepples is my hobby and i'm currently reading through a book called "c++: the complete reference". on page 77 the author is talking about "loops with no bodies" and says:
"Time delay loops are often used in programs. The following code shows how to create one by using for:
for(t=0;t<SOME_VALUE;t++);"

i looked in the appendix and that seems to be the only mention of it in the book.
can someone please kindly tell me what the fuck it is useful for? it just seems to be a waste of processing power.
am i missing something?

Name: Anonymous 2008-04-01 22:24

>>10
Troll failed.

>>1
To add to >>12, any self-respecting compiler would (assuming SOME_VALUE is some constant) unroll the loop, then use constant substitution to reduce the entire thing into a single constant-time expression (t=SOME_VALUE). Then, when it sees that t isn't referenced anywhere (and is just an integer constant) it might mark the whole section as dead code and omit it from the binary altogether (possibly not, dead code removal can do weird shit sometimes).

The point is, -O3 is considered harmful.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List