|
|
|
|
|
by jakobe
4497 days ago
|
|
Lot's of people suggesting to add explanatory comments. I don't think that's a good idea, it would be better to change the names of the variables: unsigned counter1 = 1;
unsigned counter2 = 5;
unsigned counter3 = 7;
or use an array: unsigned counter[3] = {1,5,7};
No more confusion. That being said, I doubt that the names of these local variables is actually a real source of confusion and is not a problem that needs to be fixed. |
|
That's absolutely horrible: you've now introduced the possibility of accidental out-of-bounds access where there previously was none, not to mention that you just forced the compiler to put those variables on the stack instead of using registers.
Contrived example:
The output is quite different (gcc -c -O3 -std=gnu99): Arrays mean memory - don't use them unless you actually want the compiler to use memory.