You've stumbled on one of the tricky points of mixing signed and unsigned values. The result of the sizeof operator is unsigned, but d is signed and negative. You can just pretend the comparison looks like this, because that's what actually happens:
for (d = -1; (unsigned)d <= (TOTAL_ELEMENTS - 2); d++)
Given that little tidbit, it's easy to see why the loop doesn't execute, because -1 when converted to unsigned will be a huge value, far greater than TOTAL_ELEMENTS - 2. This is due to the rule of unsigned wrapping. When you go negative, the value wraps around from the largest value.
One possible fix is to force both parts of the comparison to be signed:
for (d = -1; d <= (int)(TOTAL_ELEMENTS - 2); d++)
Another is to avoid starting at -1 in the first place. The following is a conventional counted loop setup that starts at 0 and goes until N-1. It's highly recommended:
for (d = 0; d < TOTAL_ELEMENTS; d++)