Middle of the Function

A coworker has been struggling to resolve a bug in our system for about 5 days. Part of the problem is that he keeps getting distracted by other work. However he made a goal of knocking this thing out by the end of the week.

Three were strange things happening. Perusing the code made it look like those things should never happen. So this developer put a bunch of breakpoints in the code. Actually he inserted a bunch of message boxes to slow things down and alert him to what was happening.

He traced the code down into one particular call to a funciton. The function looked simple. It was supposed to retrieve a string from the registry. However it was coming back with the wrong string. So he traced in with the debugger. That's when he saw what was going on. In the middle of the function, somebody put some code to return a constant string. All the other code below it was not getting executed.

You would think that the compiler would warn you about the unreachable code. It probably was. However that was getting lost in the million other warnings that race by in the build. Your eyes can deceive you when you trace code. However the debugger does not lie, not usually at least.