Hacker News new | ask | show | jobs
by astrange 1149 days ago
> Knowing how much memory your numbers take up is important for many applications, so I find things like "auto i = 5" to be questionable.

Automatic variables[0] don't take up any defined amount of memory. They certainly don't take up exactly sizeof(i) memory.

Struct members and global variables are more likely to do what you say; in that case it will be either not be allowed or will be sizeof(int). Conversely, `long i = 5` is two different sizes (long vs int) which could be a latent bug.

[0] aka local variables, not `auto` variables