News for hackers. Stuff that matters.
Re:Infinite loop in C by laveur on Thursday June 13, 2013 @11:11AM (#5874446)
There are so many things wrong with that code its not even funny...

First off counter is of type static int. not unsigned int like the article says. Secondly j is decremented, j isn't even defined.

They are however right that it most likely will crash due to an overflow problem. Though this is not necessarily true.

Re:Infinite loop in C by drivers99 on Thursday June 13, 2013 @11:17AM (#5874487)
"int" is signed unless you specify "unsigned". So "static int" would be a signed int that is also static.

Also, I see no reason why it would crash. Once it gets to the max value, incrementing would return some other value but I've never seen C produce a runtime error for an integer overflow.

Re:Infinite loop in C by tompko on Thursday June 13, 2013 @11:30AM (#5874570)
Technically an overflow on a signed variable results in undefined behaviour so it could crash out, but all the compilers I've tried just wrap around.