The Loop

How to piss off a customer.

int i;
for (i=0; i < theList.size(); i++);
{
   theList[i].something = 0;
}

= crash.

Since I couldn't run the code (couldn't come up with data that would ever cause that code to run), it took me a day to figure out what the problem was. Any of you C/C++/etc peeps see the problem?

4 thoughts on “The Loop

      1. cleek

        i’m a little surprised that none of the compilers or static code analysis tools we use here even bothered with a warning. i know it’s perfectly legal, but it’s unusual, and the presence of braces immediately following the ‘for’ should be a hint that i didn’t intend to do a bodiless loop.

Comments are closed.