View Single Post
Old Apr 19th, 2008, 8:32 PM   #10
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,005
Rep Power: 5 lectricpharaoh will become famous soon enough
Re: String Selection Sort

Quote:
Originally Posted by Jabo
actually, it will run once 17 is exceeded; if that ever happens. I haven't looked at the code to see.
Since it's initialized to zero there, the next statement that could modify it would be either in the loop (which won't execute if it's zero) or after the loop (in which case it's too late, because the loop is done). The only possible way this could execute is if some other process, thread, or hardware (think memory-mapped I/O) modified the variable in between the initialization and the test. As it wasn't declared volatile, I don't see this happening, as the value would probably be cached in a register. In fact, given the lack of the volatile keyword as a clue to the compiler, any intelligent optimizer would probably eliminate the loop entirely.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote