> particularly if you have the declaration far from where you are allocating memory.
So
Code:
int *p;
// lots of code
p = malloc( 10 * sizeof(int) );
If it's a long way away, how will you cope with this bug-trap?
You decide ints are no longer enough, so you want a bigger type.
Code:
long int *p;
// lots of code
p = malloc( 10 * sizeof(int) );
OOPS - you're no longer allocating the right amount of memory!
You're not going to get a compiler warning for getting the size wrong.
Unless you get lucky, and it crashes on the first test, this kind of bug can easily disappear for months or years before resurfacing.
Getting the compiler to use the variable to obtain the size information saves you from having to maintain the same information in multiple locations.
Or from having to worry about what it means if such information appears to be different.