6 ms·
> If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static storage duration is n
by shadowofneptune 4y ago
> If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static storage duration is not initialized explicitly, then:
• if it has pointer type, it is initialized to a null pointer;
• if it has arithmetic type, it is initialized to (positive or unsigned) zero;
[end quote]
—C99 Standard, §6.7.8
EDIT: That said, it can only relied upon to be zero at the first call of the function.
- InfiniteRand 4y agoI’ve seen a couple boards that purely ignore this, at least for some TI targets their position is if they supply some obscure linker option that makes it possible to initialize static memory then they’ve satisfied the standard
- Kamq 4y agoSurely this would be the compiler's job to emit the right instructions. I mean, they can do things that make it easier or harder, but satisfying a language spec isn't what they do (unless you want to count an ISA as a language spec, which it kind of is).