It is a static buffer char []

I have this in the file area:

static char foo[256];

Is memory initialized to zero on all platforms and build configurations? (i.e. is standard C ++).

+5
source share
1 answer

Is memory initialized to zero on all platforms and build configurations?

Yes, all non-local variables are initialized to zero.

(i.e. is a C ++ standard)

Yes. C ++ 11 3.6.2 indicates how non-local variables are initialized. In particular:

  1. Variables with static storage duration or stream storage duration must be zero initialized before any other initialization.
+13
source

Source: https://habr.com/ru/post/1202325/


All Articles