Initialization in C++ is Seriously Bonkers
&gt; [Why is a global variable zero?] Because i has static storage duration, it’s initialized to unsigned zero. Why, you ask? Because the standard says so.<p>No, it&#x27;s because i lives in an area allocated at the OS level, and OS has to have initialized that memory with <i>something</i> (otherwise you&#x27;d have a security bug).  The .bss segment has been zeroed, for obvious reasons, since the advent of modern linkage.<p>The explanation is backwards.  The reason that stack variables are <i>UN</i>initialized is (contra the article which thinks it&#x27;s because the programmer didn&#x27;t put an initializer in the source code) that memory is on the stack, which is allocated internal to your program and in practice was used previously by some other call for some other purpose.<p>The fact that stack variables are uninitialized by default is actually an intentional feature, not a bug, as it correctly expresses the behavior of the runtime environment.  Now, it may not be a <i>good</i> feature, and modern language designs have omitted it (by, let&#x27;s remember, relying on much better modern compilers to elide all the extra code that would otherwise have been needed to zero out a stack frame!).<p>But it&#x27;s got nothing to do with the syntax of the language.  You can rely on .bss being zero in assembly, and similarly be surprised that stack memory is going to have junk in it.