A Programmer Backed Up a Loop Counter That the Same Loop Kept Overwriting
A Daily WTF submission blamed a mysterious memory problem. The code itself assigned a string length to the counter.

The loop initialized k and l together, incremented both and used l for a customer identifier. A comment explained that k kept getting clobbered, so the second counter acted as a backup.
Then the submitted code supplied the culprit: k = strlen(someOutputString) - 8;.
Remy Porter’s original report, based on Pierre’s submission, quotes the author’s diagnosis as “some sort of memory violation.” The assignment was sitting in the same loop. A variable had been asked to be both a position and a length, and the comment promoted the ensuing confusion into a hardware-adjacent mystery.
The loop header shows why the backup could make the output look healthier than the control flow. It tests k < customers, increments both variables, and prints l + 1 as the customer identifier. Giving the printed identifier its own counter can keep that number marching upward while k is being reassigned underneath the condition that decides whether another iteration happens.
The separate assignment gives k a second meaning: the length of a string minus eight. Whatever that calculation was intended to represent, it has no reason to track the number of customers already visited. The same storage location has acquired two responsibilities that can demand different values during one trip through the loop.
The comment makes the investigation harder by giving the surprise a premature explanation. Someone reading a claim of memory corruption might begin looking for damaged buffers or unsafe pointers. The visible write to k is a simpler explanation supported by the excerpt. The name being short does not make the assignment supernatural.
Porter notes that the output functions are wrapped in macros. The published fragment does not show everything those macros do, so it would be a mistake to announce that the rest of the program is harmless. Finding one demonstrated cause answers the counter question without certifying code the report never supplied.
A focused repair would first identify what the string-length result is for and give that value a separate variable. Then the customer loop’s condition and printed identifier can be inspected together. Merely declaring k inside the loop would shrink its visibility while still allowing the assignment in the body to change it.
A useful reproducer would retain the string value and customer count from a failing run. Those inputs would expose whether the reassignment advances or rewinds the counter in that case. Until then, the excerpt establishes the conflicting uses, while the complete program retains the consequences.
The report supplies an excerpt, not the complete program. It does not establish every effect of the bug or identify the business that ran it. The visible lines are enough to diagnose this reassignment without inventing an outage around it.
A future maintainer would still need the complete loop and a real input to determine whether it skips customers, stops early or takes some other route. The next useful artifact is that failing input. Another counter would merely give the mystery a roommate.