I have the following
char mem_pool[1024*1024*64];
int main() {
// ...
}
I'm trying to get a thorough understanding how will mem_pool
be initialized. After a lot of search my conclusions are :
- it's a static initialization (not as in
static
the keyword, but as in "run before the program does - during static initialization phase") - it will run in 2 phases : zero initialization and default initialization (the second phase won't do anytning)
- it's an array of PODs so the default initialization for every element should apply, but due to the previous 2 points we won't have an array of indeterminable values (as we would with a
char ar[N]
in a function scope) but an array of zeroes.
Could someone help me dissambiguate what's guaranteed by the language and correct me if I'm wrong ?
I also thought of doing any of the following
char mem_pool[1024*1024*64] {};
char mem_pool[1024*1024*64] = "";
I suspect it's a better/recommended practice, but for now I need to understand my initial question.